Thread history

From Talk:Jetson/Cameras
Viewing a history listing
Jump to: navigation, search
Time User Activity Comment
09:26, 21 August 2016 X92127 (talk | contribs)

New thread created

18:07, 21 August 2016 Shervin.emami (talk | contribs)

New reply created

(Reply to How to do I change the USB camera resolution?)

At the recommendation of this wiki, I purchased a Logitech C615 USB web cam to use with my NVIDIA TK1. My TK1 has Ubuntu 14.04.1 LTS

The camera is capable of 1920x1080, which I have verified using Cheese, as well as: sudo apt-get install luvcview luvcview -d /dev/video0 -L

However, when I run my Python code using OpenCV, the most I can get is 800 x 448. I've tried using the embedded OpenCV that comes with L4T (2.4.13), but several websites specifically indicate that the resolution is fixed at 640 x 480 and that since Feb 1, 2016 NVIDIA is still "working on a fix".

Next, I tried a native compile of OpenCV (2.4.8) but I still can't get higher resolutions.

I tried enabling USB 3.0, but that didn't make a difference. I bought a USB 3.0 hub <-- no luck either. I also tried adding usbcore.usbfs_memory_mb=1000 to the end of extlinux.conf <-- no luck. I also tried adding vmalloc=384M to the end of extlinux.conf <-- no luck. I also tried patching lib4vl as described at this site <-- no luck!

I'm running out of options. Has anyone figured out a way to get max resolution out of a USB webcam plugged into the TK1 so that it can be used with Python / OpenCV? I'm a bit disappointed that NVIDIA has all the hype of being the "go-to" platform for computer vision, yet a simple plug-and-play webcam doesn't work right out of the box.

Thanks in advance for your help!

09:26, 21 August 2016

Hi, you should ask your question on NVIDIA's devtalk forum, since this page only really gets viewed by me and Bill.

Anyway since you're obviously trying many things about your camera resolution problem, there are several things that can effect camera resolution, but since you didn't mention it I'll mention that you should try setting the resolution at runtime in OpenCV, in case that works:

#include <stdio.h>
// Include OpenCV's C++ Interface
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;

int main() {
   VideoCapture camera;
   printf("Accessing camera 0 ...\n");;
   if ( !camera.isOpened() ) {
       cerr << "ERROR: Could not access camera " << 0 << " !" << endl;
   // Try to set the camera resolution. Note that this only works for some cameras on
   // some computers and only for some drivers, so don't rely on it to work!
   camera.set(CV_CAP_PROP_FRAME_WIDTH, 1920);
   camera.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);
   return 0;

If that doesn't work, it might be because USB2.0 doesn't normally support 1920x1080 video unless if the video is compressed by the webcam hardware, and so the driver and/or your code needs to grab compressed video frames and decompress them. Ideally V4L2 does that for you seemlessly, but sometimes it needs some configuration for it to work. Some sample commands for setting resolution on command-line before running your OpenCV program:

   v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=YUYV
   v4l2-ctl --set-fmt-video=width=1920,height=1088,pixelformat=4   # For Raspberry Pi Cam
   v4l2-ctl -v width=1280,height=720,pixelformat=BGR3

Or you can try building Gstreamer into your OpenCV library then use Gstreamer to grab the camera frame and pass it to OpenCV. It actually just needs changing 1 line of your code if you do it that way, but takes some time playing with Gstreamer for it to work.

If you have any issues, post them on the devtalk Jetson TK1 forum.

Good luck! - Shervin.

18:07, 21 August 2016