How to do I change the USB camera resolution?

Jump to: navigation, search

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

 

Return to Thread:Talk:Jetson/Cameras/How to do I change the USB camera resolution?.

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");
   camera.open(0);
   if ( !camera.isOpened() ) {
       cerr << "ERROR: Could not access camera " << 0 << " !" << endl;
       exit(1);
   }
   
   // 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);
   
   processImages(camera);
   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.

shervin.emami (talk)18:07, 21 August 2016