Ubuntu Open CV Video Capture - python

I got a problem with open cv real-time video capturing from camera. I have tried many solutions/suggestions which are available out there but not working for me. Following are the problems:
cap = cv2.VideoCapture(0)
when I tried to get video with this following error comes up:
[ WARN:0] VIDEOIO ERROR: V4L: can't open camera by index 0
Could not open video device
<VideoCapture 0x7fd99e6b5330>
Even though it is reading the video reference.
And from one solution by https://github.com/skvark/opencv-python/issues/124 I tried with
cap = cv2.VideoCapture(-1)
But this does not worked for me as it gives the error:
Video device not found
By trying sudo modprobe bcm2835-v4l2 command I got modprobe: FATAL: Module bcm2835-v4l2 not found in directory /lib/modules/4.15.0-66-generic this error. I'm not finding a way to get out of it.
It is working fine on my MacBook locally but when I tried to deploy on Ubuntu server I'm facing these errors in loop. Can anyone help me on it? Thanks in advance.

Can you open your webcam through other apps?
If not firslty try to reinstall webcam driver.
if you can do it, either some app is using webcam so cv2 can't get access to it or you did not install 3rdparty libraries to work with cameras/videos. You need to install them properly before building OpenCV Python bindings.
( you can find some info there: https://github.com/opencv/opencv/issues/8471 )

Following is the response from hosting server:
"The directory video0 would not exist because our droplets do not have any peripherals attached to them. The function cv2.VideoCapture() attempts to obtain the video capture from a webcam which a droplet would not have.
If you are wanting to stream a remote feed you should be able to do this via RTSP:
https://stackoverflow.com/questions/29099839/opencv-stream-from-a-camera-connected-to-a-remote-machine"
The problem is with droplet which don't have that functionality which we are trying to achieve.
Thanks to all for your love, support and help. Really appreciated. It might help someone else as well.

Related

Access USB device on Mac in python using pyusb an libusb

I would like to read the signal from a USB keyboard that is attached to my MacBook Pro. I am using PyCharm to write my script and I installed pyusb and libusb for the backend. Really, I am at the very beginning so please excuse my little knowledge. The problems I am faced with is that I do [Errno 13] permission error when running the script in PyCharm or when saving it and running it with PyLauncher I get a "No backend available error".
The final aim of this project is to control the vlc-media player using the vlc module based on the input of a usb device.
The current code:
import usb
import libusb_package
backend = libusb_package.get_libusb1_backend()
# find device
keyboard = usb.core.find(idVendor=0x046d, idProduct=0xc318, backend = backend)
if keyboard is None:
raise ValueError('ADU Device not found. Please ensure it is connected.')
sys.exit(1)
usb.util.claim_interface(keyboard, 0)
I would really appreciate any hints or suggestions what packages to use, which tutorials to read for usb devices and python and how to improve in this project.
Thank you very much!
All the best,
ie

Cannot connect into web camera using opencv

I have a program that is a face recognition application and I want to run it on a PC client.
But it shows an error like this
I think it might be that the program cannot connect to any camera device in my client ,
in my python code i use this
cap=cv2.VideoCapture(0)
and i have install logitech camera driver in my client pc
but it is still can not detect any camera in my client
how can i solve this?
I've had this issue before and what solved it for me was using a different USB port on the PC for the webcam. It was due to the driver being connected to certain ports that opencv read from.

Raspberry pi portaudio not working with python

I recently purchased the I2s microphone from adafruit and wired it to my raspberry Pi 3 Model A+. I want to use the module as the microphone but use the on board audio jack for the speaker. 
Initially this worked with the terminal when recording with arecord and playing with aplay. When trying to use Python PyAudio it gave me many alsa errors and Jack errors such as:
jack server is not running or cannot be started
PyAudio:
import pyaudio
P = PyAudio()
I traced the error to be called in the initialization of PyAudio at the
pa.initialize()
The code did not break but didn't function how I wanted it to. I am hoping to use the speech recognition library but when I run it once again I get all these errors and then it just listens forever. When I used a timeout it would just give an error saying time out.
Would really appreciate any help, I have been stuck on this all week. I've looked across lots of simular issues and have not found a solution.

How to fix "VIDEOIO ERROR: V4L: can't find camera device" when opening a camera with Python OpenCV?

I am trying to use Python OpenCV on a Windows Ubuntu terminal for a research project. However, when I try to open my camera to capture video I get VIDEOIO ERROR: V4L: can't find camera device. How can I access my camera using OpenCV?
I tried to use v4l2-ctl --list-devices and I get Failed to open /dev/video0: No such file or directory. The camera on my computer works when using the camera application.
I am using the following cv2 command to grab the video capture device.
import cv2
stream = cv2.VideoCapture(-1)
Ubuntu for Windows is based on Windows Subsystem for Linux (WSL). WSL does not provide hardware support so it can't provide you with a driver for your camera. See this question as well.

OpenCV VideoCapture cant open/read url

My current OpenCV version is 2.4.13. Python version is 2.7.11. My operating system is OS X Yosemite 10.10.5. I've been trying to use VideoCapture() to read url but keep getting this:
WARNING: Couldn't read movie file
VideoCapture() works fine with my laptop's webcam and local files. For example, I can open and play video like this:
cv2.VideoCapture("sg04video.mov")
But I am trying to access my ip camera with OpenCV. At first I thought I had the wrong url or it was some authentication problem. I disabled authentication, tried several camera urls(both rtsp and http) and could open them in VLC player. VLC player can also open other resources like this one: random rtsp video link
I even managed to open the url for capturing camera view image in my browser.
But cv2.VideoCapture cant open any of those urls, both video and image, whether its for my own camera or from the internet. Im sure the problem is not with the ip camera.
I am relatively new to programming and I installed OpenCV following this guide:
Installing OpenCV 2.4.9 on Mac OSX with Python Support
Please help!! Thanks!

Categories