Check camera activity
Hello
How can I check a camera activity?
I would like to know is camera on/off AND is any program currently use a camera? I tested the code from https://docs.opencv.org/3.0.0/d8/dfe/...
int main(int, char**)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat edges;
namedWindow("edges",1);
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
cvtColor(frame, edges, COLOR_BGR2GRAY);
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
Canny(edges, edges, 0, 30, 3);
imshow("edges", edges);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
I opened Skype -> Setting -> Camera Preview. Camera switched on. Then I executed the code. Only in "for" section after line "cap>>frame;" I understood than another program has already captured the camera.
I found out that by check:
if (frame.rows == 0 && frame.cols == 0 && frame.data == 0)
If I close Skype and call from the code
cap>>frame; or cap.grab(); or cap.read(frame);
I turn camera on. (I see light on my device). Is it possible to check camera activity without starting "record video" ?
I tried to compare different properties when camera on and off.
double prop1= cap.get(CAP_PROP_POS_MSEC);
double prop2= cap.get(CAP_PROP_POS_FRAMES);
...
double prop18= cap.get(CAP_PROP_WHITE_BALANCE_BLUE_U);
double prop19= cap.get(CAP_PROP_RECTIFICATION);
But the results are the same.
Is exists approach to check camera activity without "switch camera on" for a second?