#include <SC1ModCam.hpp>
Public Types | |
enum | ERRCODE { ERR_OK = 0, ERR_ERROR, ERR_WARN, ERR_FATAL } |
Public Member Functions | |
SC1ModCam (string devname="/dev/video", int parport=0x378) | |
Initialize the class. | |
~SC1ModCam () | |
Free memory and close the device. | |
unsigned long | set_exposure (unsigned long msecs) |
Set exposure time in milliseconds. | |
unsigned long | get_exposure (void) |
Get exposure time in milliseconds. | |
unsigned long | set_multiplier (unsigned int m) |
Set number of frames to drop. | |
unsigned long | get_multiplier (void) |
Get number of frames that will be dropped. | |
unsigned int | set_fps (unsigned int fps) |
Set frames-per-second for camera. | |
unsigned int | get_fps (void) |
Get number of frames per second. | |
bool | set_resolution (int width, int height) |
Set capture resolution of camera. | |
void | get_resolution (int *width, int *height) |
Get capture resolution from camera. | |
void * | get_buffer (void) |
Get pointer to buffer containing image. | |
size_t | get_buffer_size (void) |
Get size of buffer in bytes. | |
bool | take_photo () |
Take exposure (synchronously). | |
enum ERRCODE | error (string *msg=NULL) |
Get error code and descriptive string. | |
Protected Member Functions | |
void | _set_error (string error, enum ERRCODE code=ERR_ERROR) |
void | _unset_error (void) |
bool | _sync_settings (void) |
Synchronizes camera settings with local values. | |
bool | _setup_camera (void) |
Sets up all hardcoded settings and calls _sync_settings(). | |
bool | _open_shutter () |
Set pin 2 on the parport low, starting the exposure. | |
bool | _close_shutter () |
Set pin 2 on the parport high, stopping the exposure. | |
void | _usleep (unsigned long usecs) |
Sleep for the specifed number of microseconds. | |
Protected Attributes | |
string | _error_string |
enum ERRCODE | _error_code |
void * | _buffer |
int | _multiplier |
int | _fps |
int | _image_width |
int | _image_height |
int | _devfd |
Static Protected Attributes | |
const float | _bytes_per_pixel = 1.5 |
This class allows you to control a pwc-compatible camera that has been modified according to the SC1 Modifiction:
This class has been tested with a Philips ToUcam PRO II (PCVC840K) but should work with any camera supported by the pwc driver:
http://www.smcc.demon.nl/webcam/
|
Initialize the class. This calls various other functions to set defaults:
|
|
Set pin 2 on the parport high, stopping the exposure. Currently, this function always returns true.
|
|
Set pin 2 on the parport low, starting the exposure. Currently, this function always returns true.
|
|
Sets up all hardcoded settings and calls _sync_settings().
|
|
Synchronizes camera settings with local values. Used in the constructor to set all the default values in the camera.
|
|
Sleep for the specifed number of microseconds. The system call nanosleep(2) is used in this implementation.
|
|
Get error code and descriptive string. If msg is null or not specified, only the error code is returned.
|
|
Get pointer to buffer containing image. It only makes sense to call this function after calling take_photo(). If you call this function before take_photo, you will receive a null pointer.
|
|
Get size of buffer in bytes. Use this to avoid reading an incomplete image.
|
|
Get capture resolution from camera. This function assumes that the internal variables reflect reality. In proper operation, this should be fine.
|
|
Set exposure time in milliseconds. The actual exposure time may be shorter than the specified exposure time by as much as (1/FPS). A warning will be generated if the exposure time is set to less than 1 second. Exposure times this short have been known to result in corrupted frames.
|
|
Set frames-per-second for camera. The FPS will be set in the class and on the camera itself. If the camera does not support the given FPS value, an error of type ERR_WARN will be set and the current value will be returned.
|
|
Set number of frames to drop. The long exposure is taken by grabbing a bunch of frames and throwing most of them away. This function sets approximately how many frames get dropped.
|
|
Set capture resolution of camera.
|
|
Take exposure (synchronously). This function takes the long exposure synchronously, meaning it blocks the calling function for the entire length of the exposure.
|