A brother first volume sigh, this Austrian ~. This is what G8 event, nearly blindly installed 3g OpenCV, results in vain.
。
。
into question.! Environmental Python2.7
Stern lattice follow what steps. Will succeed:
The required software is as follows:
Videocapture:http://videocapture.sourceforge.net/videocapture-0.9-5.zip
MyEclipse plug-in Pydev:http://ncu.dl.sourceforge.net/project/pydev/pydev/pydev%202.7.1/pydev%202.7.1.zip
Pil:http://effbot.org/media/downloads/pil-1.1.7.win32-py2.7.exe
1. After extracting videocapture, find Python27. Copy the contents into the appropriate folder for your Python installation. It is recommended that the SRC tools outside the Python27 be copied only as appropriate.
2. PiL can be installed directly
3. Pydev is extracted and copied directly to the dropins in the MyEclipse. The environment here is configured online with a lot of catching.
The environment is ready for completion. The code is as follows:
Fromvideocapture Import Device
Importtime, String
Interval= 2
Cam =device (devnum=0, showvideowindow=0)
#cam. Setresolution (648,480)
Cam.savesnapshot (' Image.jpg ', timestamp=3, Boldfont=1, quality=75)
i = 0
Quant =interval *. 1
Starttime= Time.time ()
While 1:
Lasttime = now = Int ((time.time ()-starttime)/interval)
Print I
Cam.savesnapshot (' image.jpg ', timestamp=3,boldfont=1)
i + = 1
While now = = Lasttime:
now = Int ((Time.time ()-starttime)/interval)
Time.sleep (Quant)
You can run it directly.
Trial execution, haha:
Specific explanations and extensions:
Explanations for the various parameters of the device include the following:
class Device:
"" " Create instances of this class which would then representvideo devices.
For the lifetime of the instance, Thedevice are blocked, so it can
Used by and applications (which is quitenormal Windows behavior).
If you want to access the device Fromanother.
The instance first (e.g del cam).
"""
def __init__ (Self, devnum=0, showvideowindow=0):
"" " devnum: Videocapture enumerates the available video capture devices
On your system. If you had more than one device, specify
The desired one here. The device number starts from 0.
showvideowindow:0. Do notdisplay a video window (the default)
1 ... display avideo window
Mainly used fordebugging, since the video window
Can not be Closedor moved around.
The various parameters of SaveSnapshot are explained as follows:
def SaveSnapshot (self, filename, timestamp=0, boldfont=0, Textpos=default_textpos, **keywords):
"" " Saves a snapshot to theharddisk.
The filetype depends on thefilename extension. Everything that PIL
Can handle can specified (Foo.jpg,foo.gif, foo.bmp, ...).
Filename:string containing the name of the Resultingfile.
timestamp: See GetImage ()
Boldfont: See GetImage ()
textpos: See GetImage ()
Additional keyword arguments can begive which is just passed to the
Save () method of the Image class. For example you can specify the
Compression level of a JPEG image byquality=75 (which is the default
Value anyway).
The various parameters of GetImage are explained as follows:
def GetImage (Self, timestamp=0, boldfont=0, Textpos=default_textpos):
"" " Returns a PIL Image instance.
timestamp: 0 ... notimestamp (the default)
1 ... simple timestamp
2 ... timestamp Withshadow
3 ... timestamp withoutline
Boldfont: 0 ... normal font (the default)
1 ... bold font
Textpos: The position of thetimestamp can bespecified by a string
Containing a combination oftwo characters. One character
Must be either T or B, theother one either L, C or R.
T ... top
b ... bottom
L ... left
C ... Center
R ... right
The default value is 'bl'
A program written to help you understand the above procedure:
Import time
a=2
B=a*.1
I=0
Print B
Stime = Time.time ()
Print Stime
m=2
While M>i:
Lasttime = now = Int ((time.time ()-stime)/a)
Print (' I is:%s ')%i
I+=1
print ' Enter while Loop '
While now ==lasttime:
now = Int ((time.time ()-stime)/a)
Print (Time.time ()-stime)/A
Print (' Now is:%s ')%now
Print (' Lasttime is:%s ')%lasttime
If now ==lasttime:
Print (' Lasttime = = Now ')
Else
Print (' Lasttime not equal to now ')
Time.sleep (b)
Print ' Hibernate%s second '%b
Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.
Python camera Lens