I have opened webcam for capturing using OpenCV in C++. Then I stopped the program using CTRL+Z;
The webcam could not turn off, Because was not defined in program. And I can not start my program again because the capture program is still using webcam and is busy.
Error:
libv4l2: error setting pixformat: Device or resource busy
HIGHGUI ERROR: libv4l unable to ioctl S_FMT
...
I found the process id using lsof|grep libv4l2
:
capture 5591 mylove mem REG 8,8 52584 1737777 /usr/lib64/libv4l2.so.0.0.0
and tried to close the capture using kill 5591
and also pkill capture
using normal user and root user. But the camera LED is still turned on and my program can not start.
What is fastest and best method to release/close the camera?
ps -eo uid,state,comm
? The line with your process (capture
) would be enough.