3

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?

2
  • Could you add the output of ps -eo uid,state,comm? The line with your process (capture) would be enough. Dec 16, 2014 at 23:33
  • Of course, Now I have not OpenCV on my System. I'll put it when I install if I remember. Thank you. Oct 10, 2016 at 11:44

1 Answer 1

0

When you use Ctrl+z, the process is sending to background, so never was stopped. You can see your processes in background with jobs command. And restore the process with fg command.

Try to stop the process with Ctrl+c.

1
  • Then the issue is that, I can not stop the process using Ctrl + C. Because the camera reader, is in infinite loop. and won't stop using this signal. Maybe it's better to create a function to listen to Ctrl + Z or maybe Ctrl + C signal and then close the camera using it. Oct 10, 2016 at 11:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .