Ask Your Question

Netsai Chibuku's profile - activity

2017-02-21 04:35:32 -0600 received badge  Necromancer (source)
2017-02-20 16:44:03 -0600 commented answer how can i play video

Yes, this is only approximate frame rate, as I said in my answer. It will be slightly slower than expected because it does not take into account the time to read and decode a frame. So if you need more exact timing, you need to calculate a delay for each frame. You want to display frame N at (playback_start_time_in_ms + (N * 1000 / fps)). So on each frame, you need to subtract current system time in ms from expected display time in ms, and wait that number of ms.

2017-02-20 16:29:44 -0600 commented answer Bug? opencv_test_imgproc fails, wrong path to test file

Thank you. For me, setting DOWNLOAD_EXTERNAL_TEST_DATA to true did not download anything, and actually I cannot see any references in build files to DOWNLOAD_EXTERNAL_TEST_DATA that have any effect. So maybe there is a bug after all.

I made a manual git clone of https://github.com/opencv/opencv_extra and set OPENCV_TEST_DATA_PATH to point to it, then the tests pass.

2017-02-19 22:10:03 -0600 answered a question Can Haar or Cascade classifiers be accurate enough in detecting object size?

I agree with the answer by Balaji R. To answer your exact question, the Haar classifier can only detect that there is an object, but cannot detect the exact size. That is because each scale of the classifier will match objects that are the same size as the classifier window , or a bit smaller, or a bit larger. (This is a strength of Haar classifier, it does not miss objects that fall in the gap between 2 scales!) The classifier does not know the size of the match (even in pixels), only the size of the classifier window that matched, which will be very rough estimated.

As Balaji R said. You should do a threshold on your image in the area of the match (possibly adaptive threshold) to get the ball silhouette, then measure the ball area in pixels (it is more accurate than diameter), then determine the distance. You should also undistort the camera image, because otherwise the area and shape of the silhouette will change by lens distortion, and will not correspond accurate to distance.

2017-02-19 19:59:59 -0600 answered a question how can i play video

If the playback rate is faster than you want, you need to put a sleep in between displaying frames.

Are you using cv::VideoCapture class? I think when you call grab() to get frames from a video file, it gives you the next frame immediately. It does not care what the framerate in the video file is. (From memory, maybe I am wrong.)

The easiest way is to call cv::VideoCapture::get(CAP_PROP_FPS) to get the frames-per-second of the file. Then just add a call to sleep for (1000 / fps) milliseconds after displaying each frame. If you need really exact playback rate for synchronisation, there are better ways, but this simple way is probably enough.

2017-02-19 19:59:40 -0600 asked a question Bug? opencv_test_imgproc fails, wrong path to test file

OpenCV 3.x opencv_test_imgproc fails, because some OpenCL tests try to open nonexistent files (eg. "gpu/opticalflow/rubberwhale1.png"). The files are actually in "sources/samples/data" directory. So it seems the paths in the source has not been updated. Affects at least 3.0 and 3.2.

Before I open a bug, I want to check if there is some other cause... like I missed some file copying step in building and testing, or maybe I am building old (deprecated) tests somehow. The source files concerned are:

C:\OpenCV3.2.0\sources\modules\imgproc\perf\opencl\perf_gftt.cpp(60): ::testing::Combine(OCL_PERF_ENUM(String("gpu/opticalflow/rubberwhale1.png")),

C:\OpenCV3.2.0\sources\modules\video\perf\opencl\perf_optflow_farneback.cpp(74): Mat frame0 = imread(getDataPath("gpu/opticalflow/rubberwhale1.png"), cv::IMREAD_GRAYSCALE);

C:\OpenCV3.2.0\sources\modules\video\perf\opencl\perf_optflow_farneback.cpp(77): Mat frame1 = imread(getDataPath("gpu/opticalflow/rubberwhale2.png"), cv::IMREAD_GRAYSCALE);

C:\OpenCV3.2.0\sources\modules\video\perf\opencl\perf_optflow_pyrlk.cpp(64): Mat frame0 = imread(getDataPath("gpu/opticalflow/rubberwhale1.png"), cv::IMREAD_GRAYSCALE);

C:\OpenCV3.2.0\sources\modules\video\perf\opencl\perf_optflow_pyrlk.cpp(67): Mat frame1 = imread(getDataPath("gpu/opticalflow/rubberwhale2.png"), cv::IMREAD_GRAYSCALE);

C:\OpenCV3.2.0\sources\modules\imgproc\test\ocl\test_gftt.cpp(74): Mat frame = readImage("../gpu/opticalflow/rubberwhale1.png", IMREAD_GRAYSCALE);

C:\OpenCV3.2.0\sources\modules\imgproc\test\ocl\test_gftt.cpp(75): ASSERT_FALSE(frame.empty()) << "could not load gpu/opticalflow/rubberwhale1.png";

Netsai

2014-09-10 04:07:06 -0600 received badge  Necromancer (source)
2014-09-05 01:22:53 -0600 commented answer Need explanation for viola-jones boosting

Thank you @StevenPuttemans! I just go by seminal 2001 paper on boosting by Viola&Jones: "The weak learner is constrained so that each weak classifier returned can depend on only a single feature. As a result each stage of the boosting process, which selects a new weak classifier, can be viewed as a feature selection process."[1] But English is not my first language.

[1] "Rapid Object Detection using a Boosted Cascade of Simple Features", Viola & Jones, CVPR 2001.

2014-08-31 21:02:57 -0600 answered a question opencv_traincascade sometimes loops forever (in nextImg()) ?

You might be seeing bug #3370 in OpenCV: http://code.opencv.org/issues/3370 It should be fixed in the latest OpenCV.

The change that was made to fix the bug is here: https://github.com/Itseez/opencv/commit/e59912f803c73d62ce08c3b10885a43392a17626

2014-08-31 18:26:50 -0600 commented question opencv command config and error after stages

Does it say "Cannot get new positive sample"? If so this answer may help you: http://code.opencv.org/issues/1834 See the last answer by Maria Dimashova. You already know that -numPos parameter should be less than total number of positives in vec file. But you may have to reduce -numPos parameter even more (or, add more positive samples to vec file and keep -numPos the same). Because the actual number of extra samples you need cannot be predicted easily.

2014-08-29 04:21:17 -0600 received badge  Teacher (source)
2014-08-29 03:16:55 -0600 received badge  Necromancer (source)
2014-08-29 03:10:38 -0600 answered a question Need explanation for viola-jones boosting
  1. In Viola-Jones, each weak classifier corresponds to one Haar-like feature.
  2. Probably it is an index into the "features" array which is at the end of the xml file. Each Haar-like feature in "features" array is defined by 2 rectangles, each with a weight.
2014-08-29 02:59:08 -0600 commented question opencv command config and error after stages

It seems like opencv_traincascade is not finding negative samples.

Are you using the 64-bit OpenCV? You are allocating two 2.5GB buffers, 32-bit OpenCV cannot address such buffers. What happens if you train without using -precalcValBufSize or -precalcIdxBufSize?

If you train a much smaller classifier first (say 10 positive and negative images), does it train without errors?

2014-08-29 02:38:07 -0600 commented question opencv_traincascade error : _img.rows * _img.cols == vecSize

Is your command line for opencv_createsamples (as pasted) missing a space before -h? "-w 24-h 24" Finally you can look at your resulting vec file to see if it contains the data you expect. opencv_createsamples -vec C:\Users\anthony\Dropbox\CASEY\training2.vec -view If it doesn't, you need to fix that before running opencv_traincascade

2014-08-19 23:20:14 -0600 commented question doc error at cascade_classification.html

I think if the code calculates the difference between "the sum of image pixels under the rectangle covering the whole feature (including the two white stripes and the black stripe in the middle)" and something else, then it is not implementing Haar-like features correctly (basd on my understanding of Haar-like features). So it may be more serious than a documentation issue. The correct Haar-like feature value would be the white area's sum minus 2x the black area's sum (2x because the white area is 2x the size). Or more generally, for any feature: (white sum / white area) - (black sum / black area). The sum of whole feature area (black + white) is not relevant.

2014-08-19 23:05:27 -0600 commented question Broken understainding - creating a classifier

Try viewing vec file with opencv_createsamples.exe -vec samples.vec -view You can see if the samples in it are what you expect.

2014-08-19 22:22:35 -0600 received badge  Scholar (source)
2013-07-17 23:54:38 -0600 asked a question C vs C++ API for camera calibration

Hello,

I saw that the C API for OpenCV will be deprecated soon. So I took the opportunity to upgrade my project from the C API to C++. I am having great difficulty with cv::calibrateCamera(). The parameters seem to be completely incompatible to cvCalibrateCamera2().

  1. Is it possible use cv::Mat instead of std::vector for objectPoints and imagePoints parameters to cv::calibrateCamera()? The documentation is not clear. However, after tracing through collectCalibrationData() I think it is not possible.

  2. If it is possible, what is the exact format of matrices needed? Is there an example of giving cv::Mat to cv::calibrateCamera() somewhere? I looked online briefly but I could not find one.

  3. Using std::vector<std::vector<Vec3f>> works as a parameter to cv::calibrateCamera(), however it seems that std::vector<std::vector<Vec3f>> cannot be read/written with cv::FileStorage, which would mean I cannot use it. In the XML file it appears as one long list of floats:
    <calib_object_points> 0. 0. 0. 0. 20. .... 120. 120. 0. 120. 140. 0. </calib_object_points>
    As you can see there is no indication of the number of dimensions of each vector, and it cannot be reloaded without an error. Is there a workaround for this?

This is only very early in my conversion from C to C++ API. The C++ API is meant to give shorter, easier-to-read programs, but if I may say so, my first impression is that it is harder to use.

Thanks for any suggestion

Netsai