Ask Your Question

foundry's profile - activity

2018-03-04 16:05:28 -0600 received badge  Famous Question (source)
2017-05-21 14:01:26 -0600 received badge  Notable Question (source)
2017-01-30 05:44:33 -0600 received badge  Popular Question (source)
2016-01-18 05:59:41 -0600 asked a question cv::Tracker roi size

i am trying out cv::Tracker using tutorial_introduction_to_tracker.cpp, and comparing the prepackaged algorithns (MIL, BOOSTING, MEDIANFLOW, TLD, KCF).

In all but TLD, the size of the ROI bounding box remains fixed for the duration of the video, whilst the postiion varies to more-or-less correctly track the selected object.

I would expect the size to vary during a successful track as the tracked object depth postion varies.

Is this expected behaviour? Or does it indicate that the tracker has not correctly identified the tracked object?

2015-08-20 20:02:08 -0600 received badge  Enthusiast
2015-08-13 15:09:43 -0600 received badge  Student (source)
2015-08-13 14:53:53 -0600 received badge  Editor (source)
2015-08-13 14:45:15 -0600 commented answer cv::resize() incorrect interpolation with INTER_NEAREST

You could be right. On OpenCV 2.4.11 - and I was missing two params. The correct call is resize(_inputImage, outImage, Size(256,256),0,0,INTER_NEAREST). Looking at the OpenCV 3 docs, they seem to require the same params?

2015-08-13 14:42:06 -0600 received badge  Scholar (source)
2015-08-13 14:40:20 -0600 commented answer cv::resize() incorrect interpolation with INTER_NEAREST

Thanks, as you suggested I checked my parameters and found them lacking. I had omitted the fx and fy params, so INTER_NEAREST was being interpreted as fx=0 fy was defaulting to 0 and interpolation was defaulting to INTER_LINEAR as you show here. Correct call is resize(_inputImage, outImage, Size(256,256),0,0,INTER_NEAREST);

2015-08-13 14:38:06 -0600 commented question cv::resize() incorrect interpolation with INTER_NEAREST

@sturkmen - in photoshop, you get the expected result if you set the "Resample Image" param to "Nearest Neighbour". In any case, thanks to the answers and comments here, I have found the problem - not calling with sufficient paramenters.

2015-08-13 14:36:21 -0600 received badge  Supporter (source)
2015-08-13 04:15:23 -0600 asked a question cv::resize() incorrect interpolation with INTER_NEAREST

I am trying to 'enlarge' pixels - i.e. apply resize() to increase the dimensions of an image with nearest neighbour interpolation. However I am not getting expected results.

Input image (2 x 2 pixels):

image description

Code:

  resize(_inputImage, outImage,  Size(256,256),INTER_NEAREST);
  imshow(_windowName, outImage);

Expected result (256 x 256 pixels):

image description

Actual result (256 x 256 pixels):

image description

What am I doing wrong?

_update_
Thanks to the numerous comments and answers, it transpires that I had omitted some params. The correct call is:

      resize(_inputImage, outImage,  Size(256,256),0,0,INTER_NEAREST);

The 4th, 5th and 6th params are optional with defaults. I was omitting #4 (fx) and #5 (fy), so INTER_NEAREST was getting interpreted as fx (int 0), fy was defaulting to 0, and interpolation was defaulting to INTER_LINEAR( bilinear interpolation) which gave the unexpected result.