[Sugar-devel] error in passing image from pygame to js

Puneet Kaur puneet.gkaur at gmail.com
Wed Jul 16 03:08:24 EDT 2014


*Hey,*

*I am working on camera plugin for sugar cordova.*

*I used pygame to click the user's photograph by the following code : *


    def camera(self,request):
        os.environ['SDL_VIDEO_CENTERED'] = '1'
        pygame.init()
pygame.camera.init()
        screen=pygame.display.set_mode((640,480),pygame.NOFRAME )
    camlist = pygame.camera.list_cameras()
    if camlist:
            cam = pygame.camera.Camera(camlist[0],(640,480))
cam.start()
        quit_loop=0
        base64data=None
        while quit_loop == 0:
    cam_image=cam.get_image()
    screen.blit(cam_image,(0,0))
    pygame.display.update()
    for event in pygame.event.get():
if event.type == MOUSEBUTTONDOWN:
                    data = pygame.image.tostring(screen,"RGBA")
                    base64data = base64.b64encode(data)
                    #logging.error("base64 :\n %s",base64data)
     cam.stop()
                    pygame.display.quit()
                    quit_loop=1
        logging.error("got base64 image")
        self._client.send_result(request,base64data)




*The issue is that I am not able to send data back to the javascript side
from python side.*

*I am attaching shell.log along if anyone wishes to have a look over it.*

*would be nice if someone can help me know why am I not able to send the
data to javascript side.*






Regards,
Puneet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140716/3201c58d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shell.log
Type: text/x-log
Size: 10134 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140716/3201c58d/attachment.bin>


More information about the Sugar-devel mailing list