[Sugar-devel] error in passing image from pygame to js
Gonzalo Odiard
godiard at sugarlabs.org
Wed Jul 16 07:30:45 EDT 2014
I don't know about the js part, but would be better don't use pygame.
We have a lot of problems with th interaction between pygame and gtk.
Would be better use gstreamer.
Gonzalo
On Wed, Jul 16, 2014 at 8:07 AM, Puneet Kaur <puneet.gkaur at gmail.com> wrote:
> yup, 1) I am getting the data to send
>
> 2) the loop does stops as required
>
> 3) self._client refers to the activity api in apisocket.py ( the function
> has been defined in apisoscket.py's activity api class)
>
>
>
>
>
>
> On Wed, Jul 16, 2014 at 4:15 PM, Sam Parkinson <sam.parkinson3 at gmail.com>
> wrote:
>
>> Hi,
>>
>> Are you getting data to send? Does the loop stop?
>>
>> Please give us the context (what is this self._client?).
>>
>> Thanks,
>> Sam
>>
>>
>> P.S. Don't use `while quit_loop:`, use `while True` and `break` to quit
>> the loop
>>
>>
>> On Wed, Jul 16, 2014 at 5:08 PM, Puneet Kaur <puneet.gkaur at gmail.com>
>> wrote:
>>
>>> *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
>>>
>>>
>>>
>>> _______________________________________________
>>> Sugar-devel mailing list
>>> Sugar-devel at lists.sugarlabs.org
>>> http://lists.sugarlabs.org/listinfo/sugar-devel
>>>
>>>
>>
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
>
--
Gonzalo Odiard
SugarLabs - Software for children learning
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140716/0b771c71/attachment.html>
More information about the Sugar-devel
mailing list