Help help help: can't seem to get OpenCV VideoCapture(0) to capture images on the Jetson with python

I can’t seem to get OpenCV VideoCapture to capture images on the Jetson with python or C++.
They all work fine on MacOS X, Windows7.
Webcams tried: Logitech, Philips 900, Microsoft Lifestyle, GoPro Hero4
Logitech, Philips 900 work with “cheese”.

This is the python code:
import cv2
cap = cv2.VideoCapture(0)

Gives me these errors:

What does that mean?

I’m using the latest jetpack from a couple months ago. Anybody know how to solve this? BTW, I’m a struggling newbie, new to linux and Jetson. I trying to help a robot team, I’m wiped out, running on fumes. Help please…some direction here would be helpful.
Ideas I have:

  1. Somebody said in 2014 R21 had problems like this. Should I try going back to R19? If yes, is that easy? Does ANYBODY have R21 working with Webcams? Can I just buy a known good webcam off amazon?
  2. Cheese works. Should I download the source and investigate?
  3. Somebody said use V4L to capture video, sounds good, use a LD_PRELOAD command to force a link or something, but I can’t seem to get the V4l, is apt-get install libv4l-0 supposed to work?

Hi ComputersNCars,
Thanks for reporting the issue, we are currently investigating the case and we’ll let you know when we have an update.
In the meantime, you can try using the TK1 camera module through gstreamer and/or the nvgstcapture-1.0 sample.

gst-launch-1.0 nvcamerasrc ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)I420, framerate=(fraction)30/1' ! nvtee ! nvoverlaysink -e


Hi Kayccc,

I am having the same issue. Installed NVIDIA 6.5 and OpenCV4Tegra 24.12.3 on my Jetson TK1 under L4T 21.3.

I tested the sample program “./edge” from openCV and it is working correctly.

When I tested my Logitech 920 webcam with the sample program “./laplace” from openCV, I got the same error:

This program demonstrates Laplace point/edge detection using OpenCV function Laplacian()
It captures from the camera of your choice: 0, 1, … default 0
./laplace [camera #, default 0]

Corrupt JPEG data: 1 extraneous bytes before marker 0xd2
Corrupt JPEG data: 2 extraneous bytes before marker 0xd5
Corrupt JPEG data: 1 extraneous bytes before marker 0xd2

As decribed by ComputerNCars, the same error appears when I try to grab frames of the camera from python (using cv2).

I have all the dependencies for v4l2 correctly installed and I have changed the usb port from 2.0 to 3.0, but that didn’t solve the problem.

Someone has previously suggested in the forum that this might be a problem with ffmpeg ( Could you please confirm this?

Is this a driver problem, a lack of functionality from openCV4Tegra (“The highgui module does not include video IO and User Interface functionality”,|Mobile%20Technologies|OpenCV%20for%20Tegra|_____5) or a bug in a library?

Thanks a lot


I just uninstalled openCV4Tegra and installed openCV 2.4.9 following this link (there are several important tweaks):

Now my camera is working and I can read frames with cv2 from python

openCV4Tegra does not support some videoIO features…