Skip to content

Commit

Permalink
JNAPC-520 Aquire method added to AVTCamera
Browse files Browse the repository at this point in the history
  • Loading branch information
oostendo committed Apr 23, 2014
1 parent a6229a4 commit 8b01144
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions SimpleCV/Camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -3017,7 +3017,7 @@ def __init__(self, camera_id = -1, properties = {}, threaded = False):
self._buffer = deque(maxlen=self._buffersize)
self._thread.start()
self.threaded = True
self.frame = None
self._refreshFrameStats()

def restart(self):
Expand Down Expand Up @@ -3189,7 +3189,7 @@ def setProperty(self, name, value, skip_buffer_size_check=False):

return err

def getImage(self):
def getImage(self, timeout = 5000):
"""
**SUMMARY**
Extract an Image from the Camera, returning the value. No matter
Expand All @@ -3202,7 +3202,18 @@ def getImage(self):
>>>c.getImage().show()
"""

if self.threaded:
if self.frame != None:
st = time.time()
try:
pverr( self.dll.PvCaptureWaitForFrameDone(self.handle, ct.byref(self.frame), timeout) )
except Exception, e:
print "Exception waiting for frame:", e
print "Time taken:",time.time() - st
raise(e)
img = self.unbuffer()
self.frame = None
return img
elif self.threaded:
self._thread.lock.acquire()
try:
img = self._buffer.pop()
Expand All @@ -3213,7 +3224,7 @@ def getImage(self):

else:
self.runCommand("AcquisitionStart")
frame = self._getFrame()
frame = self._getFrame(timeout)
img = Image(pil.fromstring(self.imgformat,
(self.width, self.height),
frame.ImageBuffer[:int(frame.ImageBufferSize)]))
Expand Down Expand Up @@ -3266,6 +3277,16 @@ def _getFrame(self, timeout = 5000):

return frame

def aquire(self):
self.frame = self.AVTFrame(self.buffersize)
try:
self.runCommand("AcquisitionStart")
pverr( self.dll.PvCaptureQueueFrame(self.handle, ct.byref(self.frame), None) )
self.runCommand("AcquisitionStop")
except Exception, e:
print "Exception aquiring frame:", e
raise(e)


class GigECamera(Camera):
"""
Expand Down

0 comments on commit 8b01144

Please sign in to comment.