Ask Your Question

MFmaniak's profile - activity

2017-01-10 00:51:01 -0600 commented question solvePnP-RANSAC crashes.

Probably the problem is in types of what you're passing to solvePnP. list_points3d and list_points2d are floats and rvec, tvec, distCoeffs (not sure for _A_matrix) are doubles. And also the possible problem is in your extrinsic guess (the values of rvec and tvec, that are passed as inputs) as long as your useExtrinsicGuess is true.

2017-01-10 00:39:50 -0600 commented question problem in my solvePnPRANSAC code

I suppose something is wrong with your camera matrix. The principal point is (1, 1), based on your code. The principal point is the optical center of the image. Ideally you need to calibrate your camera, i.e. using cv::calibrateCamera (see the docs). Keep in mind that the precision of pose estimation is heavily dependent on the calibration quality (correctness of camera matrix and distortion coefficients values).

2017-01-10 00:25:31 -0600 commented question OpenCV 3.0, cv::Canny (TBB version) fails while running in parallel threads

Issue fixed in OpenCV 3.2.0

2016-10-16 14:05:34 -0600 received badge  Supporter (source)
2016-10-16 03:08:05 -0600 received badge  Enthusiast
2016-10-15 12:09:37 -0600 answered a question 31 linkage errors while building OpenCV_world dll on VS2013 with Qt
  1. Moc the file window_QT.h (moc.exe window_QT.h -o moc_window_QT.cpp).
  2. Include ..\opencv\3.1\sources\modules\highgui\src\moc_window_QT.cpp in solution.
2015-09-07 02:07:53 -0600 commented question OpenCV 3.0, cv::Canny (TBB version) fails while running in parallel threads

Thanks for quick reply. I'll post this as an issue. The problem isn't in thread-safety of the cv::Mat itself. The data, that is processed in my threads, doesn't intersect at all. I process 3 different videostreams.

2015-09-07 00:41:14 -0600 commented question OpenCV 3.0, cv::Canny (TBB version) fails while running in parallel threads

I'm still wondering if this is a bug in OpenCV. Can someone make it clear for me? Thanks in advance.

2015-09-07 00:40:03 -0600 commented question OpenCV 3.0, cv::Canny (TBB version) fails while running in parallel threads

Just to be clear - the code in post is a part of cv::Canny source code from "canny.cpp" (OpenCV 3.0.0). I've found a workaround that suites my needs. I've changed cv::Canny definition to pass a custom parameter.

CV_EXPORTS_W void Canny( InputArray image, OutputArray edges,
                         double threshold1, double threshold2,
                         int apertureSize = 3, bool L2gradient = false, void* bp = NULL);

And in my worker object (one for each parallel thread) i create an instance of

tbb::concurrent_queue<uchar*> borderPeaks

and pass a reference to it in cv::Canny() call. So the data parts that are pushed into borderPeaks queue inside cv::Canny are not mixed between threads.

2015-09-04 09:29:38 -0600 received badge  Editor (source)
2015-09-04 09:19:27 -0600 asked a question OpenCV 3.0, cv::Canny (TBB version) fails while running in parallel threads

Hello, everyone. I have a project under Qt 5.5, TBB 4.4, OpenCV 3.0.0 (compiled with IPP and TBB). Building under MSVS 2012 u5. I have 3 equal parallel threads (but for 2 this isssue is also actual). In each of them I process a 100Hz video stream (1280x1024x8bit) coming from my device. In frame preprocessing I call cv::Canny(src, dst, 50, 200, 3, true) in each of 3 parallel processing loops. I am catching exception in canny.cpp in the following section of code:

#define CANNY_PUSH_SERIAL(d)    *(d) = uchar(2), borderPeaks.push(d)

// now track the edges (hysteresis thresholding)
uchar* m;
while (borderPeaks.try_pop(m))
{
    if (!m[-1])         CANNY_PUSH_SERIAL(m - 1);
    if (!m[1])          CANNY_PUSH_SERIAL(m + 1);
    if (!m[-mapstep-1]) CANNY_PUSH_SERIAL(m - mapstep - 1);
    if (!m[-mapstep])   CANNY_PUSH_SERIAL(m - mapstep);
    if (!m[-mapstep+1]) CANNY_PUSH_SERIAL(m - mapstep + 1);
    if (!m[mapstep-1])  CANNY_PUSH_SERIAL(m + mapstep - 1);
    if (!m[mapstep])    CANNY_PUSH_SERIAL(m + mapstep);
    if (!m[mapstep+1])  CANNY_PUSH_SERIAL(m + mapstep + 1);
}

I figured out that when it happens, 2 different threads are trying to get access to object referenced by m that is equal in both threads. My guess that this is happening because of borderPeaks queue is defined as static global object.

#ifdef HAVE_TBB

// Queue with peaks that will processed serially.
static tbb::concurrent_queue<uchar*> borderPeaks;

So it appears that i can't run TBB version of cv::Canny in multiple parallel threads. Compiling without TBB support fixes the issue. Or even compiling with TBB-dependent section of cv::Canny being commented also fixes this. But in both the performance of cv::Canny is decreasing.

Is this a bug, and do i have any performance saving workaround?

PS. I forgot to say, that I've got this issue only when running Release version. Debug build is working fine.