The CameraImage class
Use the function
to retrieve an instance of the
class.
Attribute |
Access |
Type |
Description |
name |
R |
string |
the name of the camera image |
index |
R |
int |
index of camera image (zero index, 0..n-1) |
active |
R/W |
bool |
active state |
intermediate |
R/W |
bool |
intermediate state |
autoClear |
R/W |
bool |
auto clear state |
camera |
R/W |
string |
name of connected camera |
cameraNo |
R/W |
int |
camerano of connected camera (zero index,
0..n-1) |
rotation |
R/W |
0/1 |
0=None, 1=90, 2=180, 3=-90, 4=VFlip, 5=HFlip |
simulation |
R/W |
0/1 |
current state of individual simulation flag |
path |
R/W |
string |
image path when simulation |
filter |
R/W |
string |
image filter when simulation (ex : *_0.bmp,
*_1.jpg, *.* ) |
fileRotation |
R/W |
int |
rotation when in simulation, values see above
for values |
filename |
R |
string |
filename of current image in simulation mode |
grabDuration |
R |
int |
duration between grab command and received image
of last image |
Method |
Returns |
Description |
resetFilename() |
bool |
resets the filename in simulation
mode (reset simulation cycle) |
The CameraImages class
Use the function
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 |
all names as tuple |
simulation |
R/W |
0/1 |
state of simulation, an active simulation state
overrides the individual settings and sets all cameras in
simulation mode |
path |
W |
string |
sets path for all camera images.
Note that this
is write only since each CameraImage may have individual paths.
It is recommended to read the path of camera 1 if you want to
set all paths equal |
defaultPath |
R |
string |
default path when adding camera images, equals
the profile path |
Method |
Returns |
Description |
get(index) |
CameraImage |
returns a CameraImage instanse if
valid index |
getCameraImage(name) |
CameraImage |
returns a CameraImage instanse if
valid name |
resetFilenames() |
0/1 |
resets filenames for all cameraImages
in simulation mode (resets simulation cycle) |
configure(code=0) |
bool |
launches configuration dialogs due to
code parameter
code=0: complete images configuration dialog
code=1: folder dialog
code=2: sequence dialog
code=3: filter dialog |
load(filename) |
bool |
load configuration from file |
save(filename) |
bool |
save configuration to file |
Example 1: Change simulation path according to context def Handle_System_AfterContextChange(Context):
#
# Context = VT_BSTR
#
#set path of simulation images
imgs=GetCameraImages()
imgs.path=imgs.defaultPath+'\\'+Context
for i in range(imgs.count):
if Context=='V1': #the simulation images are JPEG's for product V1, the other products are bmps
imgs.get(i).filter='*_%i.jpg' % i
else:
imgs.get(i).filter='*_%i.bmp' % i
return 0
Example 2: Reset filename for simulation def ResetSimulation(path):
imgs=GetCameraImages()
imgs.resetFilenames() #resets simulation filename cycle
Example 3: Change the
cameraNo by cameraName def ChangeCamera(image, cameraNo):
camImg=GetCameraImage(image) #get camera image by name
camImg.cameraNo=cameraNo #set the attached camera
Example 4: ImageNo by ImageName def GetImageNoByImageName(name):
camImages=GetCameraImages()
for index in range(camImages.count):
if camImages.get(index).name == name:
return index
return -1
Example 5: ImageNo by ImageName def GetImageNoByImageName(name):
return GetCameraImage(name).index #implemented in Scorpion 11.1.0.634
Example 6: Load image configuration def
LoadImageConfig():
import os
folder=GetStringValue('System.Profile')
fname=os.path.join(folder,'ImageConfig.spb')
print fname,GetCameraImages().load(fname)
|