|
|
|
@ -15,6 +15,11 @@
|
|
|
|
|
|
|
|
|
|
VideoDev_SVBCam::VideoDev_SVBCam() {
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
inframe = NULL;
|
|
|
|
|
inframe_size = 0;
|
|
|
|
|
inframe_pixfmt = 0;
|
|
|
|
|
inframe_w = 0;
|
|
|
|
|
inframe_h = 0;
|
|
|
|
|
camid = -1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -196,7 +201,8 @@ int VideoDev_SVBCam::Open() {
|
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (convert_to_pixelformat(conf_format)) {
|
|
|
|
|
inframe_pixfmt = convert_to_pixelformat(conf_format);
|
|
|
|
|
switch (inframe_pixfmt) {
|
|
|
|
|
case (V4L2_PIX_FMT_RGB32):
|
|
|
|
|
if ((err = SVBSetOutputImageType(camid, SVB_IMG_RGB32)) != SVB_SUCCESS) {
|
|
|
|
|
print_error(err);
|
|
|
|
@ -210,7 +216,8 @@ int VideoDev_SVBCam::Open() {
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
conf_format = convert_from_pixelformat(V4L2_PIX_FMT_RGB24);
|
|
|
|
|
conf_format = convert_from_pixelformat(V4L2_PIX_FMT_RGB24);
|
|
|
|
|
inframe_pixfmt = V4L2_PIX_FMT_RGB24;
|
|
|
|
|
if ((err = SVBSetOutputImageType(camid, SVB_IMG_RGB24)) != SVB_SUCCESS) {
|
|
|
|
|
print_error(err);
|
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
@ -221,9 +228,8 @@ int VideoDev_SVBCam::Open() {
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// preprare buffer
|
|
|
|
|
LockMutex();
|
|
|
|
|
threaddata.vf.SetSize(camprop.MaxWidth, camprop.MaxHeight);
|
|
|
|
|
UnLockMutex();
|
|
|
|
|
conf_width = inframe_w = camprop.MaxWidth;
|
|
|
|
|
conf_height = inframe_h = camprop.MaxHeight;
|
|
|
|
|
|
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
|
};
|
|
|
|
@ -252,6 +258,8 @@ int VideoDev_SVBCam::Close() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prepare inframe for raw picture data, will hold a video frame with 16bit per channel
|
|
|
|
|
* inframe size = 2*3*W*H
|
|
|
|
|
* send the start capture signal to the cam
|
|
|
|
|
*/
|
|
|
|
|
int VideoDev_SVBCam::CaptureStart() {
|
|
|
|
@ -264,10 +272,21 @@ int VideoDev_SVBCam::CaptureStart() {
|
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// allocate memory for frame data
|
|
|
|
|
if (inframe != NULL) free (inframe);
|
|
|
|
|
inframe_size = 6 * inframe_w * inframe_h;
|
|
|
|
|
inframe = (unsigned char*) malloc(inframe_size);
|
|
|
|
|
|
|
|
|
|
ConvertStart(&cdata, inframe_pixfmt);
|
|
|
|
|
|
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* free inbuffer
|
|
|
|
|
*/
|
|
|
|
|
int VideoDev_SVBCam::CaptureStop() {
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
@ -277,6 +296,15 @@ int VideoDev_SVBCam::CaptureStop() {
|
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// free inframe memory
|
|
|
|
|
if (inframe) {
|
|
|
|
|
free (inframe);
|
|
|
|
|
inframe_size = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConvertStop(&cdata, inframe_pixfmt);
|
|
|
|
|
|
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -290,14 +318,16 @@ int VideoDev_SVBCam::CaptureStop() {
|
|
|
|
|
int VideoDev_SVBCam::Grab(VideoFrame *vf) {
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
LockMutex();
|
|
|
|
|
if ((err = SVBGetVideoData(camid, threaddata.vf.data, (long)threaddata.vf.size, 50)) != SVB_SUCCESS) {
|
|
|
|
|
if (inframe == NULL) return VDEV_STATUS_ERROR;
|
|
|
|
|
if ((err = SVBGetVideoData(camid, inframe, (long)inframe_size, 50)) != SVB_SUCCESS) {
|
|
|
|
|
if (err != SVB_ERROR_TIMEOUT) {
|
|
|
|
|
print_error(err);
|
|
|
|
|
UnLockMutex();
|
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LockMutex();
|
|
|
|
|
Convert(&cdata, vf, inframe, inframe_size, inframe_pixfmt, inframe_w, inframe_h);
|
|
|
|
|
UnLockMutex();
|
|
|
|
|
|
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
|