The Camera class
Use the function GetCamera(name) to retrieve an instance of the
class.
The name may be replaced by the camera index as string,
cam=GetCamera('0')
Attribute |
Access |
Type |
Description |
name |
R/W |
string |
the name of the camera - name change trigger a
close and open |
index |
R |
int |
index of camera [0..> |
grabber |
R |
int |
assigned grabberno [0..> |
port |
R |
int |
assigned portno [0..> |
driver |
R/W |
string |
the cameradriver for this camera |
width |
R |
int |
width of image |
height |
R |
int |
height of image |
open |
R/W |
0/1 |
0=closed, 1=open |
hwtrigger |
R/W |
0/1 |
0=off, 1=on |
calibrated |
R |
0/1 |
0=uncalibrated 1=calibrated |
pitch |
R |
(x,y,unit) |
returns pitch tuple (float,float,string) |
|
|
|
|
errorColor |
R/W |
byte |
pixelvalue of error images |
errorFile |
R/W |
string |
filename of error images |
timeoutDelay |
R/W |
int |
timeout period in ms |
timeoutColor |
R/W |
byte |
pixelvalue of timeout images |
timeoutFile |
R/W |
string |
filename of timeout images |
fifoColor |
R/W |
byte |
pixelvalue of fifo images. Note! flush() must be
called after changed |
fifoFile |
R/W |
string |
filename of fifo images. Note! flush()
must be called after changed |
|
|
|
|
grabDuration |
R |
int |
statistics - duration of last grab command in
micro seconds |
minDuration |
R |
int |
statistics - min grabDuration since reset |
maxDuration |
R |
int |
statistics - max grabDuration since reset |
openCnt |
R |
int |
statistics - no of times camera has been opened |
imageCnt |
R |
int |
statistics - no of images since reset |
timeoutCnt |
R |
int |
statistics - no of image timeouts since reset |
grabErrCnt |
R |
int |
statistics - no of errors since reset |
delayCnt |
R |
int |
statistics - no of delayed images since reset |
maxBuffered |
R |
int |
statistics - max no if images buffered |
maxDMA |
R |
int |
statistics - max duration of retrieving image
from cameradriver |
|
|
|
|
Method |
Returns |
Description |
getPropertyRange(name) |
int, int | None |
returns min and max of the property.
|
getProperty(name) |
int | None |
returns current value of the
property. |
setProperty(name,value) |
0/1 |
returns 0 on fail, else 1 |
|
|
|
flush() |
bool |
flushes the camera image fifo
used to resync the system |
reset() |
bool |
reopens the camera,
can be used to handle image
size changes |
|
|
|
executeCmd(cmd,params="") |
0/1 |
send a command request to camera.
The "cmd" and "params" are driver/camera specific, see
documentation for actual cameradriver for supported commands. |
|
|
|
edit([tabindex]) |
0/1 |
open the camera configuration
dialog.
Optional tabindex (string) may be given to show one page
only.
Tabindex='0' launches the advanced dialog if
supported by camera. |
|
|
|
resetStatistics() |
0/1 |
reset statistics |
The CameraList class
Use the function GetCameras() to get the list of all defined
cameras in Scorpion.
Attribute |
Access |
Type |
Description |
count |
R |
int |
number of defined cameras in system |
names |
R |
tuple |
return
all connected cameranames as tuple
eg ('XCG-V60E-92719444806066', 'XCG-V60E-92719444805454')
camera names are important - used to identify the camera and key
the configuration |
openCount |
R |
int |
number of open cameras in system
count is 0 in simulationMode |
Method |
Returns |
Description |
setOpen(value) |
0/1 |
Open all active cameras in CameraList
value=0 to close, value=1 to open.
Returns 1 if all cameras opened successfully,
else 0. |
getCamera(index) |
object | None |
returns a camera object if index is
in range. The index is zero-based. |
reset() |
0/1 |
returns 1 for ok, 0 for error.
Note
that the reset command can not be called from within the
camera error handler. |
|
|
|
flush() |
0/1 |
flushes image fifo buffers for all
cameras |
browse() |
string |
returns a string list of cameranames of all currently available cameras
returns "" when no connected camera |
configure() |
bool |
launches the configuration
dialog for all cameras |
|
|
|
load(filename) |
bool |
Load CameraList configuration from file |
save(filename) |
bool |
Save CameraList configuration to file |
|
|
|
setDriver(filename) |
bool |
Sets Scorpion Camera Driver
eg 'hvgrab.dll" for all cameras |
Example 1: Define a Camera Error Handle in Central def Handle_System_CameraError(CameraNo,Camera):
#
# CameraNo = VT_I4
# Comment = VT_BSTR
#
cam=GetCamera(Camera)
if cam<>None:
print 'Camera name:',cam.name if cam.open:
print cam.name, ' is open'
else:
print cam.name, ' is closed' Example
2: Iterate all cameras to get open state cameras=GetCameras()
if cameras<>None:
n=cameras.count
if cameras.openCount<>n:
for i in range(n):
cam=cameras.getCamera(i)
if cam<>None:
print i,cam.name,cam.open Example
3: Iterate all cameras to set camera Properties - Shutter and Gain def
SetCameraProperties():
#-----------------------------
def setProperyAllCam(prop,val):
cams=GetCameras()
for i in range(cams.count):
cam=cams.getCamera(i)
if cam.setProperty(prop,val)==0:
print 'set',prop,'failed'
print cam.name, prop, cam.getPropertyRange(prop),cam.getProperty(prop)
setProperyAllCam('shutter',450)
setProperyAllCam('gain',190)
Example
4: Toggling continous for all cameras in profile
def
ToggleContinous():
cams=GetCameras()
continous=cams.getCamera(0).getProperty('continous')
for i in range(cams.count):
cam=cams.getCamera(i)
cam.setProperty('continous',not continous)
print cam.name,getCamera(0).getProperty('continous')
Example 5: Statistics report def CameraStat(cameraname):
cam=GetCamera(cameraname)
print 'Camera ',cameraname
print 'GrabDuration ',cam.grabDuration
print 'MinDuration ',cam.minDuration
print 'MaxDuration ',cam.maxDuration
print 'OpenCnt ',cam.openCnt
print 'ImageCnt ',cam.imageCnt
print 'TimeoutCnt ',cam.timeoutCnt
print 'GrabErrCnt ',cam.grabErrCnt
print 'DelayCnt ',cam.delayCnt
print 'MaxBuffered ',cam.maxBuffered
print 'MaxDMA ',cam.maxDMA
cam.resetStatistics() Example 6: Load camera configuration
def LocaCameraConfig():
import os
folder=os.path.join(GetStringValue('System.Profile'),'Hardware')
sysname=GetStringValue('System.SystemName')
hwid=GetStringValue('System.HWID')
fname=os.path.join(folder,'%s_%s.spb'%(sysname,hwid))
print fname,GetCameras().load(fname)
|