mirror of
https://github.com/opencv/opencv.git
synced 2025-06-27 06:51:16 +08:00
use struct member width_set/height_set to replace static width/height.
the static variables will cause race-condition when operating in multithread scenarios. Signed-off-by: Teng Yiliang <ylteng@outlook.com> Signed-off-by: Teng Yiliang <yiliang.teng@weimob.com>
This commit is contained in:
parent
05f0cb16de
commit
dadde75ef0
@ -277,6 +277,7 @@ struct CvCaptureCAM_V4L CV_FINAL : public CvCapture
|
|||||||
|
|
||||||
__u32 palette;
|
__u32 palette;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
int width_set, height_set;
|
||||||
int bufferSize;
|
int bufferSize;
|
||||||
__u32 fps;
|
__u32 fps;
|
||||||
bool convert_rgb;
|
bool convert_rgb;
|
||||||
@ -795,6 +796,7 @@ bool CvCaptureCAM_V4L::open(const char* _deviceName)
|
|||||||
FirstCapture = 1;
|
FirstCapture = 1;
|
||||||
width = DEFAULT_V4L_WIDTH;
|
width = DEFAULT_V4L_WIDTH;
|
||||||
height = DEFAULT_V4L_HEIGHT;
|
height = DEFAULT_V4L_HEIGHT;
|
||||||
|
width_set = height_set = 0;
|
||||||
bufferSize = DEFAULT_V4L_BUFFERS;
|
bufferSize = DEFAULT_V4L_BUFFERS;
|
||||||
fps = DEFAULT_V4L_FPS;
|
fps = DEFAULT_V4L_FPS;
|
||||||
convert_rgb = true;
|
convert_rgb = true;
|
||||||
@ -1748,7 +1750,6 @@ static bool icvSetControl (CvCaptureCAM_V4L* capture,
|
|||||||
|
|
||||||
static int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
|
static int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
|
||||||
int property_id, double value ){
|
int property_id, double value ){
|
||||||
static int width = 0, height = 0;
|
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
bool possible;
|
bool possible;
|
||||||
|
|
||||||
@ -1757,6 +1758,9 @@ static int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
|
|||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
case CV_CAP_PROP_FRAME_WIDTH:
|
case CV_CAP_PROP_FRAME_WIDTH:
|
||||||
|
{
|
||||||
|
int& width = capture->width_set;
|
||||||
|
int& height = capture->height_set;
|
||||||
width = cvRound(value);
|
width = cvRound(value);
|
||||||
retval = width != 0;
|
retval = width != 0;
|
||||||
if(width !=0 && height != 0) {
|
if(width !=0 && height != 0) {
|
||||||
@ -1765,8 +1769,12 @@ static int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
|
|||||||
retval = v4l2_reset(capture);
|
retval = v4l2_reset(capture);
|
||||||
width = height = 0;
|
width = height = 0;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case CV_CAP_PROP_FRAME_HEIGHT:
|
case CV_CAP_PROP_FRAME_HEIGHT:
|
||||||
|
{
|
||||||
|
int& width = capture->width_set;
|
||||||
|
int& height = capture->height_set;
|
||||||
height = cvRound(value);
|
height = cvRound(value);
|
||||||
retval = height != 0;
|
retval = height != 0;
|
||||||
if(width !=0 && height != 0) {
|
if(width !=0 && height != 0) {
|
||||||
@ -1775,7 +1783,8 @@ static int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
|
|||||||
retval = v4l2_reset(capture);
|
retval = v4l2_reset(capture);
|
||||||
width = height = 0;
|
width = height = 0;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case CV_CAP_PROP_FPS:
|
case CV_CAP_PROP_FPS:
|
||||||
capture->fps = value;
|
capture->fps = value;
|
||||||
retval = v4l2_reset(capture);
|
retval = v4l2_reset(capture);
|
||||||
|
Loading…
Reference in New Issue
Block a user