projekty
/
imago.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6d19451
)
even more comments
author
Tomas Musil
<tomik.musil@gmail.com>
Tue, 24 Jun 2014 01:46:29 +0000
(
03:46
+0200)
committer
Tomas Musil
<tomik.musil@gmail.com>
Tue, 24 Jun 2014 01:46:29 +0000
(
03:46
+0200)
imago_pack/camera.py
patch
|
blob
|
history
diff --git
a/imago_pack/camera.py
b/imago_pack/camera.py
index
d5dac75
..
a4521d0
100644
(file)
--- a/
imago_pack/camera.py
+++ b/
imago_pack/camera.py
@@
-1,3
+1,8
@@
+"""Camera module.
+
+This module handles various backends (different for every OS) for streaming the video from a (web)camera.
+"""
+
import os
if os.name == 'posix':
import os
if os.name == 'posix':
@@
-6,6
+11,13
@@
if os.name == 'posix':
import cv
class Camera:
import cv
class Camera:
+ """Implement basic camera capabilities
+
+ This class has different implementations for different OS. On posix
+ systems it calls to opencv, on Windows to VideoCapture."""
+ # TODO what about win 64?
+ # TODO why not openCV on win?
+ # TODO document VideoCapture as a dependency
def __init__(self, vid=0, res=None):
self._cam = cv.CreateCameraCapture(vid)
if res:
def __init__(self, vid=0, res=None):
self._cam = cv.CreateCameraCapture(vid)
if res:
@@
-14,11
+26,9
@@
if os.name == 'posix':
res[1])
def get_image(self):
res[1])
def get_image(self):
- for _ in range(5): #HACK
+ """Get a new image from the camera."""
+ for _ in range(5): #HACK TODO document this
im = cv.QueryFrame(self._cam)
im = cv.QueryFrame(self._cam)
- # Add the line below if you need it (Ubuntu 8.04+)
- #im = cv.GetMat(im)
- #convert Ipl image to PIL image
return Image.fromstring("RGB", cv.GetSize(im), im.tostring(), "raw",
"BGR", 0, 1)
return Image.fromstring("RGB", cv.GetSize(im), im.tostring(), "raw",
"BGR", 0, 1)
@@
-41,3
+51,6
@@
elif os.name in ('ce', 'nt', 'dos'):
def __del__(self):
del self._cam
def __del__(self):
del self._cam
+
+else:
+ pass # TODO exception "Cannot recognise OS." or back to posix?