Ask Your Question

Michał Rus's profile - activity

2020-12-10 02:49:18 -0600 received badge  Nice Question (source)
2017-05-31 09:35:21 -0600 received badge  Famous Question (source)
2015-10-14 08:49:59 -0600 received badge  Notable Question (source)
2015-05-22 05:56:02 -0600 received badge  Notable Question (source)
2015-05-22 02:04:23 -0600 received badge  Popular Question (source)
2014-08-13 06:23:14 -0600 received badge  Popular Question (source)
2013-06-07 12:54:59 -0600 received badge  Scholar (source)
2013-06-07 12:41:30 -0600 commented answer Recognize basic shapes in binarized image

Thanks for the suggestions. It occurs matchShapes with "normal" moments (and with template contours) does the trick.

2013-06-07 12:40:21 -0600 commented answer matchShapes always returns 0

@berak It works. :) Thanks!

2013-06-07 12:38:56 -0600 commented answer Recognize basic shapes in binarized image

Thanks for approxPolyDP suggestion. :) I used matchShapes using some template images.

2013-06-07 12:37:42 -0600 received badge  Supporter (source)
2013-06-07 07:38:01 -0600 commented answer matchShapes always returns 0

Ahh... So the solution would be to use stable? 2.4.5? Have you filed a bug report already?

2013-06-07 03:15:11 -0600 received badge  Student (source)
2013-06-06 23:06:28 -0600 asked a question matchShapes always returns 0

I'm using matchShapes to recognize some basic contours. However, it's returning 0, no matter what contours I compare...

Template images:

circle cross enter image description here

Examplary input image:

empty triangle, empty circle, cross

The code:

using std::vector;
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;

findContours(binary, contours, hierarchy,
             CV_RETR_CCOMP, CV_CHAIN_APPROX_TC89_KCOS);

drawContours(binary, contours, -1, Scalar(255, 255, 255));

if (!contours.size()) // avoid sigsegv
    return;

for (int idx = 0; idx >= 0; idx = hierarchy[idx][0]) {
    double bestMatch = INFINITY;
    int bestI = -1;
    for (int i = 0; i < knownContours.size(); i++) {
        vector<Point>& a = knownContours[i].contour;
        vector<Point>& b = contours[idx];
        std::cout << "a.size = " << a.size() << ", b.size = " << b.size() << std::endl;
        double match = matchShapes(b, a, CV_CONTOURS_MATCH_I1, 0);
        std::cout << "idx=" << idx << " ? " << knownContours[i].name << " = " << match << std::endl;
        if (bestI == -1 || match < bestMatch) {
            bestI = i;
            bestMatch = match;
        }
    }
}

(knownContours are obviously initialized with template image data: imread(), then findContours(), finally this->contour = contours[0]).

And resulting output (a fragment):

-- new frame
a.size = 57, b.size = 74
idx=0 ? circle = 0
a.size = 80, b.size = 74
idx=0 ? cross = 0
a.size = 45, b.size = 74
idx=0 ? triangle = 0
a.size = 57, b.size = 60
idx=1 ? circle = 0
a.size = 80, b.size = 60
idx=1 ? cross = 0
a.size = 45, b.size = 60
idx=1 ? triangle = 0

-- new frame
a.size = 57, b.size = 75
idx=0 ? circle = 0
a.size = 80, b.size = 75
idx=0 ? cross = 0
a.size = 45, b.size = 75
idx=0 ? triangle = 0
a.size = 57, b.size = 57
idx=1 ? circle = 0
a.size = 80, b.size = 57
idx=1 ? cross = 0
a.size = 45, b.size = 57
idx=1 ? triangle = 0

-- new frame
a.size = 57, b.size = 76
idx=0 ? circle = 0
a.size = 80, b.size = 76
idx=0 ? cross = 0
a.size = 45, b.size = 76
idx=0 ? triangle = 0
a.size = 57, b.size = 51
idx=1 ? circle = 0
a.size = 80, b.size = 51
idx=1 ? cross = 0
a.size = 45, b.size = 51
idx=1 ? triangle = 0

So the sizes of compared contours differ (so the contours differ), yet match == 0 always. What's going on here?

Edit: OpenCV version is 2.4.9 (cloned & built yesterday).

2013-06-06 19:34:24 -0600 asked a question Recognize basic shapes in binarized image

How can I recognize some basic (usually rotated) shapes:

  • circle,
  • "empty" circle,
  • cross,
  • empty triangle,

using OpenCV? What's the most straightforward way? It would be nice if the user could "define" his own shapes somehow (load a template image, possibly).

I'd like to map each recognized shape to its type (circle, triangle etc.) and a position of its center. (And its rotation if possible).

For circles HoughCircles could be used (there's no rotation in this case, too). But what about the others? Template matching doesn't support rotation and scaling, right?...

Here's the input:

empty triangle, empty circle, circles

empty triangle, empty circle, cross

2013-06-06 11:00:33 -0600 commented question [Solved] Linking error: undefined reference to `cv::VideoCapture::open(std::string const&)`

@berak Done. :) Would you mind taking a look at http://answers.opencv.org/question/14785/ ?

2013-06-06 10:59:37 -0600 asked a question `VideoCapture` from file fails in `ff_yuyvToY_sse2` function.

I get a SIGSEGV when trying to get a frame from an .avi file:

#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc, char *argv[])
{
    VideoCapture capture("V:/DATA/640.AVI");
    if (!capture.isOpened())
        return -1;
    Mat tmp;
    capture >> tmp;
    return 0;
}

capture >> tmp; is the failing line. Debugger says that the instruction marked below in function ff_yuyvToY_sse2 is causing the problem:

        Function: ff_yuyvToY_sse2
0x715f756a  <+0x001a>         sldt   (%eax)
0x715f756d  <+0x001d>         add    %cl,0xf66731c(%ebp)
0x715f7573  <+0x0023>         je     0x715f7547 <ff_nv21ToUV_mmx+87>
0x715f7575  <+0x0025>         psrlw  $0x8,%xmm2
0x715f757a  <+0x002a>         jne    0x715f75a2 <ff_yuyvToY_sse2+82>
0x715f757c  <+0x002c>         neg    %esi

;
; the instruction below fails:
;
0x715f757e  <+0x002e>         movdqa (%ebx,%esi,2),%xmm0

0x715f7583  <+0x0033>         movdqa 0x10(%ebx,%esi,2),%xmm1
0x715f7589  <+0x0039>         pand   %xmm2,%xmm0
0x715f758d  <+0x003d>         pand   %xmm2,%xmm1
0x715f7591  <+0x0041>         packuswb %xmm1,%xmm0
0x715f7595  <+0x0045>         movdqa %xmm0,(%eax,%esi,1)
0x715f759a  <+0x004a>         add    $0x10,%esi
0x715f759d  <+0x004d>         jl     0x715f757e <ff_yuyvToY_sse2+46>
0x715f759f  <+0x004f>         pop    %esi
0x715f75a0  <+0x0050>         pop    %ebx
0x715f75a1  <+0x0051>         ret
0x715f75a2  <+0x0052>         neg    %esi
0x715f75a4  <+0x0054>         movdqu (%ebx,%esi,2),%xmm0
0x715f75a9  <+0x0059>         movdqu 0x10(%ebx,%esi,2),%xmm1
0x715f75af  <+0x005f>         pand   %xmm2,%xmm0
0x715f75b3  <+0x0063>         pand   %xmm2,%xmm1
0x715f75b7  <+0x0067>         packuswb %xmm1,%xmm0
0x715f75bb  <+0x006b>         movdqa %xmm0,(%eax,%esi,1)
0x715f75c0  <+0x0070>         add    $0x10,%esi
0x715f75c3  <+0x0073>         jl     0x715f75a4 <ff_yuyvToY_sse2+84>
0x715f75c5  <+0x0075>         pop    %esi
0x715f75c6  <+0x0076>         pop    %ebx
0x715f75c7  <+0x0077>         ret
0x715f75c8  <+0x0078>         nop
0x715f75c9  <+0x0079>         lea    0x0(%esi,%eiz,1),%esi

0x715f757e  <+0x002e>         movdqa (%ebx,%esi,2),%xmm0

OpenCV version is 2.4.9 compiled from source (cloned yesterday).

Edit: works as expected when I remove opencv_ffmpeg.dll from PATH... It would be nice, however, to be able to use FFMPEG...

2013-06-06 10:35:30 -0600 commented question [Solved] Linking error: undefined reference to `cv::VideoCapture::open(std::string const&)`

@berak Ok, I've run make install, for some reason it also rebuilded some part of it... But it works. Thank you! Next problem is that capture &gt;&gt; frame; causes the program to crash... but at least it starts. ;p

2013-06-06 09:40:17 -0600 commented question [Solved] Linking error: undefined reference to `cv::VideoCapture::open(std::string const&)`

@berak Oh, dear God. I'm using headers from 2.4.5... But where are the headers from 2.4.9? I used CMake to compile it.

2013-06-06 09:23:44 -0600 commented question [Solved] Linking error: undefined reference to `cv::VideoCapture::open(std::string const&)`

@berak cv::String x("V:/DATA/320.AVI"); capture.open(x); instead of capture.open("V:/DATA/320.AVI"); renders the same error... cv::String is std::string.

2013-06-06 09:09:39 -0600 commented question [Solved] Linking error: undefined reference to `cv::VideoCapture::open(std::string const&)`

@berak Newest from git: 2.4.9.

2013-06-06 09:00:47 -0600 received badge  Editor (source)
2013-06-06 08:58:10 -0600 asked a question [Solved] Linking error: undefined reference to `cv::VideoCapture::open(std::string const&)`

I'm trying to use an .avi file as my source. (Camera capture already works.) My project compiles without problems, but during linking I get the error:

undefined reference to 'cv::VideoCapture::open(std::string const&)'

What should I do? In which library is this std::string overload of VideoCapture::open() put?

Edit: VideoCapture(0) (camera capture) compiles, links and works, so VideoCapture(std::string) has to be somewhere else that in libs I'm already linking with... right?

Edit: OpenCV version: 2.4.9 (cloned from git yesterday).