Ask Your Question

ilyad's profile - activity

2019-10-10 18:32:26 -0600 received badge  Student (source)
2016-02-05 10:12:58 -0600 received badge  Popular Question (source)
2014-11-03 07:24:36 -0600 received badge  Critic (source)
2014-10-29 09:48:38 -0600 commented question Antialiased polygon fill doesn't respect area borders

1) Yes, I run debug version, should it be any difference?

2) I don't understand your item "2": of course I set 4th parameter of cv::fillPoly(...) to 1, not to 0, because the documentation says: "ncontours – Number of contours that bind the filled region", and I have ONE contour, not ZERO contours.

3) I removed ".5" from all the coordinates: cv::Point2f A(5,2), B(6, 2), C(6,3), D(5, 3); The result differs a bit, but still a very wrong one: 0, 10, 10, 0 // 10, 100, 100, 12 // 10, 85, 87, 12 // 0, 12, 12, 0 //

2014-10-29 07:13:33 -0600 commented question Antialiased polygon fill doesn't respect area borders

I updated the posting: without CV_AA flag I have 3 full (100%) pixels instead of expected four pixels at 25% each.

2014-10-29 05:14:41 -0600 asked a question Antialiased polygon fill doesn't respect area borders

I want to draw a quadrilateral which vertices doesn't coincide with pixel boundaries. The simplest case is a square with all 4 vertices located exactly in the middle of pixels. Here is my code doing it:

cv::Point2f A(5.5,2.5), B(6.5, 2.5), C(6.5,3.5), D(5.5, 3.5);
cv::Point points[4] = {A, B, C, D};
const cv::Point *contours[1] = {points};
int lengths[1] = {4};

cv::Mat p(10, 10, CV_8U, cv::Scalar(0));
cv::fillPoly(p, contours, lengths, 1, cv::Scalar(100), CV_AA, 0);
std::cout << p << std::endl;

In the output image I expected 4 pixels with the value of 25%, i.e. total value of 100 (because the area of the square is exactly 1). But the real output looks like this:

[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,  19, 100,  22,   0,   0;
   0,   0,   0,   0,   0,  36, 100,  40,   0,   0;
   0,   0,   0,   0,   0,  20,  83,  22,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0]

Is this a bug in the library or do I use it in a wrong way? And how to draw a simple 1x1 antialiased square?

UPDATE: After removing CV_AA flag the output of

 cv::fillPoly(p, contours, lengths, 1, cv::Scalar(100));

looks like this:

[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0, 100,   0,   0,   0;
   0,   0,   0,   0,   0,   0, 100,   0,   0,   0;
   0,   0,   0,   0,   0,   0, 100,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0]
2014-10-10 07:08:32 -0600 commented question Crash: example from Cascade Classifier tutorial

oh, I'm happy you're here, I know your name from git commit history for the doc file. "image" is okay (but "image" is not the issue, it crashes when tries to find eyes in "face_region" after line 28) Alas, checking any of "image" or "face_region" doesn't help: both are correct images (I used the gui to output them both, I see the full image for "image" and just the black white face for "face_region")

2014-10-10 06:09:58 -0600 received badge  Editor (source)
2014-10-10 06:08:37 -0600 asked a question Crash: example from Cascade Classifier tutorial

I try to run the example program from here (tutorial for Cascade Classifier). In order to run the face/eyes classifiers on set of existing photos I changed the code and made a minimal crashing example.

If I execute the program without eye recognition, it runs successfully and detects faces:

face detector: 1 face(s) detected in collection/image_case_001.png
face detector: 3 face(s) detected in collection/image_case_002.png
face detector: 5 face(s) detected in collection/image_case_003.png
face detector: 1 face(s) detected in collection/image_case_004.png
..... etc ...... 171 images processed

As soon as I call it with "-eyes" flag it crashes in detectMultiScale call when trying to find eyes in a successfully detected face:

face detector: 1 face(s) detected in collection/image_case_001.png
now detecting eyes for the face[0]=564x564+422+442...
Segmentation fault

The same happens if I try any of my images instead of the first one, so I believe something is wrong with the program, while data is okay.

I'm using opencv from git repo, last commit is "7e8846b81e420b 2014-09-30 13:39" on Debian Linux (testing distro).

Here is my program (very short, just 36 lines)

 1 #include <iostream>
 2 #include <opencv/cv.hpp>
 3 #include <opencv/highgui.h>
 4 #include <opencv2/objdetect/objdetect.hpp>
 5 #include <opencv2/objdetect/detection_based_tracker.hpp>

 6 int main(int argc, char **argv)
 7 {
 8   cv::CascadeClassifier face_classifier, eyes_classifier;

 9   if (not face_classifier.load("haarcascade_frontalface_alt.xml") or not eyes_classifier.load("haarcascade_eye_tree_eyeglasses.xml"))
10   {
11     std::cerr << "sorry, can't load XML files" << std::endl;
12     return 1;
13   }

14   for (int no=1; no<=171; ++no)
15   {
16     char path[1024];
17     sprintf(path, "collection/image_case_%03d.png", no);

18     std::vector<cv::Rect> faces;

19     cv::Mat gray, image = cv::imread(path, CV_LOAD_IMAGE_COLOR);

20     cv::cvtColor(image, gray, CV_BGRA2GRAY);
21     cv::equalizeHist(gray, gray);

22     face_classifier.detectMultiScale (gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, cv::Size(30, 30));
23     std::cout << "face detector: " << faces.size() << " face(s) detected in " << path << std::endl;

24     if (argc > 1 and (std::string) argv[1]=="-eyes") // eyes requested on command line
25       for (unsigned i=0; i < faces.size(); ++i)
26       {
27         std::vector<cv::Rect> eyes;
28         cv::Mat face_region = gray(faces[i]);
29         std::cout << "now detecting eyes for the face[" << i << "]="
30           << faces[i].width << "x" << faces[i].height << "+" << faces[i].x << "+" << faces[i].y << "..." << std::endl;
31         eyes_classifier.detectMultiScale(face_region, eyes, 1.1, 2, 0 |CV_HAAR_SCALE_IMAGE, cv::Size(30, 30));
32         std::cout << "eyes detector: " << eyes.size() << " eye(s) detected in face[" << i << "]: " << std::endl;
33       }
34   }
35   return 0;
36 }

And here is the stack dump printed by GDB:

gdb > run -eyes
Starting program: /home/ilya/vision/./crash -eyes
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so ...
(more)
2014-10-10 04:14:04 -0600 answered a question Compiling errors (3.0.0-alpha / Master Head) on Linux

A valid workaround is to disable "FFMPEG support" in CMakeLists.txt:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5301f82..d5649b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -125,7 +125,7 @@ OCV_OPTION(WITH_CUBLAS         "Include NVidia Cuda Basic Linear Algebra Subprog
 OCV_OPTION(WITH_NVCUVID        "Include NVidia Video Decoding library support"                                OFF IF (NOT IOS AND NOT APPLE) )
 OCV_OPTION(WITH_EIGEN          "Include Eigen2/Eigen3 support"               ON)
 OCV_OPTION(WITH_VFW            "Include Video for Windows support"           ON   IF WIN32 )
-OCV_OPTION(WITH_FFMPEG         "Include FFMPEG support"                      ON   IF (NOT ANDROID AND NOT IOS))
+OCV_OPTION(WITH_FFMPEG         "Include FFMPEG support"                      OFF  IF (NOT ANDROID AND NOT IOS))
 OCV_OPTION(WITH_GSTREAMER      "Include Gstreamer support"                   ON   IF (UNIX AND NOT APPLE AND NOT ANDROID) )
 OCV_OPTION(WITH_GSTREAMER_0_10 "Enable Gstreamer 0.10 support (instead of 1.x)"                              OFF )
 OCV_OPTION(WITH_GTK            "Include GTK support"                         ON   IF (UNIX AND NOT APPLE AND NOT ANDROID) )
2014-10-02 14:48:29 -0600 commented answer Compiling errors (3.0.0-alpha / Master Head) on Linux

I did it: installed the package libx264-dev, cleaned the working directory and run "cmake . && make" again. Alas, same error message...

2014-10-02 08:13:06 -0600 asked a question Compiling errors (3.0.0-alpha / Master Head) on Linux

I tried to compile opencv from sources:

1) first from the HEAD of master branch on github and then

2) from the zip file https://github.com/Itseez/opencv/archive/3.0.0-alpha.zip

In both cases I got the same error message:

Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o In file included from /home/ilya/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:65:0, from /home/ilya/opencv/modules/videoio/src/cap_ffmpeg.cpp:45: /home/ilya/opencv/modules/videoio/src/ffmpeg_codecs.hpp:98:7: error: ‘CODEC_ID_H264’ was not declared in this scope { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },

I'm running Debian Testing distro, amd64 architecture.

Any idea what's wrong?