Sunday, 25 October 2020

OpenCV Probabilistic Hough Line Transform giving different results with C++ and Python?

I was working on a project using OpenCV, Python that uses Probabilistic Hough Line Transform function "HoughLinesP" in some part of the project. My code worked just fine and there was no problem. Then I thought of converting the same code to C++.

After converting the code to C++, the output is not the same as that of the Python code. After long hours of debugging, I found out that everything else works fine but the "HoughLinesP" function is giving different output in the case of C++. The input to this function in both the languages is the same and the values of parameters are also the same but the output from it is different.

Can someone explain me why is this happening and any possible fixes for it?

Also, I have checked the version of OpenCV for both the languages, and it is the same: 4.5.0 dev Also, I have tried playing with the values passed to the C++ code, but I am not able to obtain similar results.

Input Edge Image:

Input Edge Image

Python HoughLinesP() output:

Python HoughLinesP() output

C++ HoughLinesP() output:

C++ HoughLinesP() output

Following are the codes in each language: Python:

Lines = cv2.HoughLinesP(EdgeImage, 1, np.pi / 180, 50, 10, 15)

C++:

std::vector<cv::Vec4i> Lines;
cv::HoughLinesP(EdgeImage, Lines, 1, CV_PI / 180, 50, 10, 15);

It would be a great help if anyone could suggest something.



from OpenCV Probabilistic Hough Line Transform giving different results with C++ and Python?

No comments:

Post a Comment