コード例 #1
0
 def directSnapshotTask(self, parameters, preview, *args):
     # running on a Raspberry Pi
     #print parameters, preview, args
     try:
         if self.directCamera == None:
             try:
                 print "Using picam directly"
                 self.usingDirectPicam = True
                 from piKamPicamServer import PiKamPicamServerProtocal
                 self.directCamera = PiKamPicamServerProtocal()
             except:
                 self.usingDirectPicam = False
                 print "Using raspistill directly"
                 from piKamServer import PiKamServerProtocal
                 self.directCamera = PiKamServerProtocal()
         imageFilename, image, imageType, replyMessageType = self.directCamera.takePhoto(
             parameters)
         # Schedule to show image in main event thread
         # Do slow as much image manipulation as possible in this thread to prevent the GUI blocking
         if preview:
             # raspistill will have already saved the image, just display it.
             from functools import partial
             #self.displayPreview(textureFromPyImage(borderPyImage(image)))
             Clock.schedule_once(
                 partial(self.displayPreview, borderPyImage(image)))
         else:
             if self.usingDirectPicam:
                 # Need to write the image out.
                 image.save(imageFilename, imageType)
             from functools import partial
             Clock.schedule_once(
                 partial(self.displayImage, downsizePyImage(image)))
     except Exception, error:
         print str(error)
         self.displayError(
             'No remote hostname set, you need to be running this on a Raspberry Pi. '
             + str(error))