Opencv and image cropping (Bugfix #3210)


Added by Denis Gottardello over 11 years ago. Updated over 11 years ago.


Status:Cancelled Start date:2013-08-12
Priority:Normal Due date:
Assignee:Alexander Smorkalov % Done:

0%

Category:highgui-video
Target version:Next Hackathon
Affected version:2.4.6 (latest release) Operating System:Linux
Difficulty:Easy HW Platform:x86
Pull request:

Description

Opencv and image cropping

As you can see in the attached image (look at the red arrows) OpenCV fails on cropping image. At the left and at the top the image is not perfect.
This happens on Linux with bttv driver.
In the past I have solved by patching the OpenCV function

static int icvSetVideoSize( CvCaptureCAM_V4L* capture, int w, int h)
in cap_libvl4.cpp


OpenCV_Bug.jpeg (40 kB) Denis Gottardello, 2013-08-12 11:35 am


Associated revisions

Revision 14d53589
Added by Alexander Alekhin over 10 years ago

Merge pull request #3210 from akarsakov:ocl_gftt_opt

History

Updated by Sergei Nosov over 11 years ago

Hi, Denis! Thx for reporting!

Maybe you could submit your fixes in a pull request?

  • Status changed from New to Incomplete

Updated by Kirill Kornyakov over 11 years ago

Denis, it is not clear what exactly you don't like. I don't understand what you're trying to highlight with the red arrows. And it is not clear what you mean by image cropping, OpenCV doesn't have such function. You also mentioned a patch, can you attach it here, so we can study it?

So, please do the following, otherwise this ticket will be rejected:
  1. Attach your OpenCV code, which behavior you don't like.
  2. Explain your exact issue, and why do you think this is an OpenCV issue. May be this is a camera driver issue, then you have to attach a good image from other software, and a bad OpenCV image, so we can see the difference.
  3. Propose your solution for the problem, since we know nothing about your environment and we don't have bttv driver. So, basically you're supposed to fix the issue yourself, and send a pull request. You should understand, that we don't even have a chance to help you with such an issue...

Regards,
Kirill

  • Assignee set to Denis Gottardello
  • Target version set to Next Hackathon

Updated by Denis Gottardello over 11 years ago

Sorry but I'm not a good english speaker.
As you can see on the first attached image, with some capture adapters like the adapters that use bttv driver, OpenCV returns an image with a rectangle on the left with width 1 cm and another rectangle on the top with height 0.3 mm, look at the two red arrows.
The correct image should be as the image http://www.denisgottardello.it/OpenCV_Bug2.jpeg

I have patched the OpenCV version 2.4.3 by modifying the function
static int icvSetVideoSize( CvCaptureCAM_V4L* capture, int w, int h) {
located in cap_libv4l.cpp. The patch is only a comment of

capture->crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
capture->crop.c.left = 0;
capture->crop.c.top = 0;
capture->crop.c.height = h*24;
capture->crop.c.width = w*24;

But remember: I have copied this piece of code from OpenCV 2.4.6, the 2.4.3 version is different.

  • Status changed from Incomplete to Open

Updated by Alexander Shishkov over 11 years ago

  • Difficulty set to Easy
  • Assignee changed from Denis Gottardello to Alexander Smorkalov
  • Tracker changed from Bug to Bugfix
  • Category set to highgui-video

Updated by Alexander Shishkov over 11 years ago

Hello Denis,
thanks for submitting this issue. Unfortunately we have limited resources at the moment. So if there is a chance if you have time to fix this problem that would be highly appreciated! (Please see http://www.code.opencv.org/projects/opencv/wiki/How_to_contribute for details).

Thank you in advance!

Updated by Alexander Smorkalov over 11 years ago

Denis, thank you for your bug report, but it looks like your camera issue, but not OpenCV bug. We cannot remove force cropping setup, because it breaks some other camera support. I do not found any bttv driver related issues connected with cropping. The only thing I found is reset_crop kernel module parameter. I hope it helps you to solve issue. For more details see LinuxTV wiki: http://www.linuxtv.org/wiki/index.php/Bttv
I close the ticket.

  • Status changed from Open to Cancelled

Also available in: Atom PDF