Add pulse detection

This commit is contained in:
Kalman 2018-11-05 16:23:32 +08:00
parent 9a465b9f04
commit a57edded4b

View File

@ -41,6 +41,11 @@ namespace uvc {
LOG(severity) << str << " error " << errno << ", " << strerror(errno); \
} while (0)
#define NO_DATA_MAX_COUNT 200
#define LIVING_MAX_COUNT 9000
int no_data_count = 0;
int living_count = 0;
/*
class device_error : public std::exception {
public:
@ -385,8 +390,26 @@ struct device {
if (xioctl(fd, VIDIOC_QBUF, &buf) < 0)
throw_error("VIDIOC_QBUF");
});
if (living_count < LIVING_MAX_COUNT) {
living_count++;
} else {
living_count = 0;
LOG(INFO) << "UVC pulse detection,Please ignore.";
}
}
no_data_count = 0;
} else {
no_data_count++;
}
if (no_data_count > NO_DATA_MAX_COUNT) {
no_data_count = 0;
living_count = 0;
LOG(WARNING) << __func__ << "v4l2 get stream time out,Try to reboot!";
stop_capture();
start_capture();
}
}
void start_streaming() {