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>
__u32 palette;
int width, height;
__u32 palette;
int width, height;
+ int width_set, height_set;
int bufferSize;
__u32 fps;
bool convert_rgb;
int bufferSize;
__u32 fps;
bool convert_rgb;
FirstCapture = 1;
width = DEFAULT_V4L_WIDTH;
height = DEFAULT_V4L_HEIGHT;
FirstCapture = 1;
width = DEFAULT_V4L_WIDTH;
height = DEFAULT_V4L_HEIGHT;
+ width_set = height_set = 0;
bufferSize = DEFAULT_V4L_BUFFERS;
fps = DEFAULT_V4L_FPS;
convert_rgb = true;
bufferSize = DEFAULT_V4L_BUFFERS;
fps = DEFAULT_V4L_FPS;
convert_rgb = true;
static int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
int property_id, double value ){
static int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
int property_id, double value ){
- static int width = 0, height = 0;
bool retval = false;
bool possible;
bool retval = false;
bool possible;
switch (property_id) {
case CV_CAP_PROP_FRAME_WIDTH:
switch (property_id) {
case CV_CAP_PROP_FRAME_WIDTH:
+ {
+ int& width = capture->width_set;
+ int& height = capture->height_set;
width = cvRound(value);
retval = width != 0;
if(width !=0 && height != 0) {
width = cvRound(value);
retval = width != 0;
if(width !=0 && height != 0) {
retval = v4l2_reset(capture);
width = height = 0;
}
retval = v4l2_reset(capture);
width = height = 0;
}
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);
retval = height != 0;
if(width !=0 && height != 0) {
height = cvRound(value);
retval = height != 0;
if(width !=0 && height != 0) {
retval = v4l2_reset(capture);
width = height = 0;
}
retval = v4l2_reset(capture);
width = height = 0;
}
case CV_CAP_PROP_FPS:
capture->fps = value;
retval = v4l2_reset(capture);
case CV_CAP_PROP_FPS:
capture->fps = value;
retval = v4l2_reset(capture);