Accidently deleted /dev/video0 and can't access the web cam via cheese
Solution 1
Try the recreating the video0
nod in the /dev
directory to see if that solves your problem.
sudo mknod /dev/video0 c 81 0
sudo chown root:video /dev/video0
sudo chmod 660 /dev/video0
If you still having problem after this, try rebooting also.
Solution 2
/dev
files are not-ordinary files, such as a .txt file, but they are interface to devices, like nodes, and most important they do not reside really on your (our) disk.
/dev
files represent devices attached/on your computer, resident files are created run-rime.
The simplest solution to restore that file is to reboot your computer.
(when you power-off a computer, /dev
is empty)
As an alternative, un-plug and plug the implicated device should have the same effect.
Related videos on Youtube
mozilla-firefox
Asking and answering obvious questions on SO.
Updated on September 18, 2022Comments
-
mozilla-firefox over 1 year
To solve a issue I created another issue. I read this two code on some forum:
sudo rm /dev/video0 sudo mv /dev/video1 /dev/video0
Now I can't access my web cam plus the python script that I had earlier written is giving problem viz:
from cv2 import * cam = cv2.VideoCapture(0) # some problem over here xx=1 //capture just one picture as soon as web cam gets opened while xx<2: ret, img = cam.read() cv2.imshow('img',img) value=random.randint(1,10000) cv2.imwrite("/home/mukesh/Desktop/recognition/recognition/unknown_pictures/filename"+str(value)+".jpg",img) xx+=1 k = cv2.waitKey(30) & 0xff if k == 27: break cam.release() cv2.destroyAllWindows()
Is there any way that I can recover back my dev/video0 file and get my web cam again. I completely messed up my laptop.
-
mozilla-firefox over 5 yearsYes it worked by restarting but now in my code I had to tweak this cam = cv2.VideoCapture(0) as cam = cv2.VideoCapture(1). If it is left to 0 then an error is coming up VIDEOIO ERROR: V4L2. I am really clueless. Though it worked by changing 0 to 1 in the above code but I fail to understand the reason. Earlier it was working on 0 and not on 1 and now it's vice versa.
-
mozilla-firefox over 5 yearsYes it worked after writing above 2 commands and then aftter restarting but now in my code I had to tweak this cam = cv2.VideoCapture(0) as cam = cv2.VideoCapture(1). If it is left to 0 then an error is coming up VIDEOIO ERROR: V4L2. I am really clueless. Though it worked by changing 0 to 1 in the above code but I fail to understand the reason. Earlier it was working on 0 and not on 1 and now it's vice versa.
-
Bernard Wei over 5 yearsWhich version of Ubuntu are you using? If you are using the later releases, 16.04 or later, it may be using udev exclusively. So it automatically create video1 when udev see the video0 static nod.
-
mozilla-firefox over 5 yearsI am using Ubuntu 18.04. Maybe that's the reason then.
-
Bernard Wei over 5 yearsOkay, you can try this. Delete the static video0 we created and reboot. udev may recreate the 'video0' so your code can work with the device 0 again. You dev may be dynamic so no static nod is needed. I kinda remember it caches things so it may still like your video device to video1. But I may be wrong.
-
mozilla-firefox over 5 yearssudo rm /dev/video0 ? Is this the code to remove the static node ?
-
Bernard Wei over 5 yearsYeah, try that and reboot. It may re-link it back to video0 or it may still link the device to video1. We'll see.
-
mozilla-firefox over 5 yearsIt is working with 1 itself. Same error with 0. Actually I wanted to use IP webcam through mobile so that I can use that instead of normal webcam. Hence I tried to tweak webcam settings. My webcam is not much clear and hence image recognition is not tested properly on it.