User manual

Small Vision System User Manual 51
5.3 Continuous Capture
In continuous capture mode, the capture device sends images to main memory at video rates. A
double-buffering scheme lets user programs run asynchronously. When the user program wants a stereo
pair, it requests it with the sequence svsVideoWaitImage - svsVideoGetImage. This will give
the program a pointer to the most recent acquired stereo pair. The buffer is managed by SVS, so the
application should not free it up after processing.
int svsVideoStartContinuous(svsSP *sp)
Starts continuous video capture. The video device(s) must already have been opened with
svsVideoOpen. Images are grabbed continuously into a dual buffer at frame rates, and
can be retrieved asynchronously with svsWaitImage/svsGetImage.
When this function is called, all the frame size and digitization parameters in sp are
checked, and the cameras hardware is set up according to these parameters. The major
reason for an unsuccessful call is that the frame size parameters are not legal. Use the
svsVideoCheckParams function to check the validity of parameters before calling
svsVideoStartContinuous.
Returns 0 if successful, and a negative error number if the video stream could not be started.
The error codes are the same as for svsVideoCheckParameters, defined above.
void svsVideoHaltContinuous(void)
Halts continuous video capture.
int svsVideoWaitImage(int ms)
Waits for a frame in continuous capture mode. The ms argument is an integer specifying the
timeout period in milliseconds. Returns 1 if an image is ready, and 0 if it timed out.
Normally, because of double-buffering of the continuous image stream, this function will
return 1 immediately. Only in the case where the user program requests images faster than
the video rate will it actually wait before returning.
After a successful return, a program should call svsVideoGetImage to retrieve the image
data.
void svsVideoGetImage(unsigned char **left, unsigned char **right,
unsigned char **color)
Gets a stereo pair from the input capture buffers. left will contain a pointer to the left
image array, and right a pointer to the right image array. No data is copied by this call. If
the program intends to save this image data past the next invocation of svsGetImage, it
should be copied, since the buffers will receive new data.`
The data format for the left and right images is 8 bits/pixel grayscale, packed as a linear
array of size width x height.
If color information is available (the color parameter of the svsSP structure), it is
returned in the color array; otherwise this array is set to NULL. In the color array, each
pixel is represented as a set of four bytes, in the order RGBX.