Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 4th, 2013, 08:21 PM
kernelOD kernelOD is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 kernelOD User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 17 sec
Reputation Power: 0
Smile P2p Camera

hi guys

im trying to make a little peer-2-peer camera program using pygame,PIL and VideoCapture.

what im doing is sending pictures in a row to make a video.

my problem is that after my first picture (which appears on the client's screen!) i get an error (in the client program):
Traceback (most recent call last):
File "C:\Users\CHRIS\Desktop\CAMERA\CLIENT.py", line 36, in <module>
image = pygame.image.frombuffer(data,(90,60),"RGB")
ValueError: Buffer length does not equal format and resolution size


my code looks like this:

Server:
import socket
from VideoCapture import *
from PIL import *

server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('',5000))
server_socket.listen(5)
camera = Device()
image = camera.getImage()
print "NEW CONNECTION!"


while 1:
client_socket, address = server_socket.accept()
image = camera.getImage()
print "I got a connection from ", address

image = camera.getImage().convert("RGB")

image = image.resize((90,60))

data = image.tostring()

client_socket.sendall(data)



Client:
import socket
import pygame
import Image
import PIL
import time

timer = 20

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((socket.gethostname(),5000))

pygame.init()
screen = pygame.display.set_mode((640,480))
pygame.display.set_caption('Remote Webcam Viewer')
font = pygame.font.SysFont("Arial",14)
clock = pygame.time.Clock()

data = client_socket.recv(409600000)
image = pygame.image.frombuffer(data,(90,60),"RGB")
image = pygame.transform.scale(image,(640, 480),)
pygame.display.flip()

while 1:
output = image
while timer>0:
screen.blit(output,(0,0))
pygame.display.flip()
timer=timer-1

client_socket.close()
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((socket.gethostname(),5000))
data = client_socket.recv(409600000)
image = pygame.image.frombuffer(data,(90,60),"RGB")
image = pygame.transform.scale(image,(640, 480),)
timer=30
pygame.display.flip()



somebody help, please?


Thankes,
kernelOD

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > P2p Camera

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap