opencv videocapture open usb camera with error 'ERROR: V4L/V4L2: VIDIOC_S_CROP'

I pluged a usb camera, used the follwing code to open the camera.

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>

using namespace cv;


int main()
{
	VideoCapture cap(1);
	if(!cap.isOpened())
	{
		return -1;
	}
	Mat frame;
	Mat edges;

	bool stop = false;
	while(!stop)
	{
		cap>>frame;
		imshow("video",frame);
		if(waitKey(10) >=0)
			stop = true;
	}
	return 0;
}

Luckily, the window ‘video’ shown, but some error messages also shown in console.

HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP
Corrupt JPEG data: 1 extraneous bytes before marker 0xd3
Corrupt JPEG data: 4 extraneous bytes before marker 0xd4
Corrupt JPEG data: 3 extraneous bytes before marker 0xd5
Corrupt JPEG data: 4 extraneous bytes before marker 0xd1
Corrupt JPEG data: 2 extraneous bytes before marker 0xd5
Corrupt JPEG data: 1 extraneous bytes before marker 0xd3
Corrupt JPEG data: 1 extraneous bytes before marker 0xd6
Corrupt JPEG data: 2 extraneous bytes before marker 0xd5
Corrupt JPEG data: 2 extraneous bytes before marker 0xd1
Corrupt JPEG data: 3 extraneous bytes before marker 0xd0
Corrupt JPEG data: 3 extraneous bytes before marker 0xd1
Corrupt JPEG data: 4 extraneous bytes before marker 0xd6
Corrupt JPEG data: 10 extraneous bytes before marker 0xd7

The same code, I have tried on x86 platform pc, it works.
could anybody tell me what’s wrong?

Hi cooper_cn,

What’s the OpenCV4Tegra and BSP version you used?
The OpenCV4Tegra does not support some videoIO features, and “HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP” was reported for all cameras we’ve ever tried. It does not affect camera functionality.

Thanks

Thanks to you @kayccc

The BSP is:

$ head -n 1 /etc/nv_tegra_release 
# R24 (release), REVISION: 1.0, GCID: 7164062, BOARD: t210ref, EABI: aarch64, DATE: Tue May 17 23:37:30 UTC 2016

The OpenCV4Tegra is

libopencv4tegra_repo_2.4.13_arm64_l4t-r24.deb

I want to know the differrence between opencv v4l2 and gstreamer api, which is better on TX1, do you know?

The BSP is:

$ head -n 1 /etc/nv_tegra_release 
# R24 (release), REVISION: 1.0, GCID: 7164062, BOARD: t210ref, EABI: aarch64, DATE: Tue May 17 23:37:30 UTC 2016

The OpenCV4Tegra is

libopencv4tegra_repo_2.4.13_arm64_l4t-r24.deb

I want to know the differrence between opencv v4l2 and gstreamer api, which is better on TX1, do you know?

By opencv videocapture, the fps of logic C270 camera is very low, ~5fps @ VGA.

It’s my fault, the videocapture.read() is very fast, ~8ms, but the display is low, especially the cv.waitKey(), it needs ~200ms.

Hi cooper_cn

Regarding “I want to know the differrence between opencv v4l2 and gstreamer api, which is better on TX1, do you know?”, it depends on your use case and purpose.

You need to do the experiment to find the suitable method for your project.

Thanks

I’m having the same problem with my logitech c270 on opencv4tegra 2.4.13 (jetpack 2.3). The webcam streams fine but I get the same error messages. Was anyone able to figure out a solution?

Hi jetson24

As my previous comments: “The OpenCV4Tegra does not support some videoIO features, and “HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP” was reported for all cameras we’ve ever tried. It does not affect camera functionality.”.

Since your webcam streams fine, is there other specific issue on your case?

Thanks

I’m getting a stream of error messages similar to the OP such as: “Corrupt JPEG data: 1 extraneous bytes before marker 0xd3”

I was wondering if this was an issue. I noticed that the frame rate on my camera was dropping below 30 fps. I’m not sure if any of these are related or if it is just an issue with the webcam.

Hi jetson24,

This error message seems come from OpenCV itself, but not sure whether it’s an issue, orfixed in later version.
You may try to move on new version, such as OpenCV3.x to confirm that.

Thanks