justadudewhohacks / opencv4nodejs

Nodejs bindings to OpenCV 3 and OpenCV 4
MIT License
4.97k stars 827 forks source link

Incorrect result = Imageproc houghLinesP #548

Open je3f0o opened 5 years ago

je3f0o commented 5 years ago

Hello Vincent. I'm sorry for creating new issue without contributing. I'm very newbie for OpenCV and node bindings. Anyway, I just wanted to say my opinion about Mat.houghLinesP() method. I saw python and C++ results. They returned array of array points [ [x0,y0,x1,y1], ... ]. So I tried to learn this method in my javascript code. Because I love javascript. But Mat.houghLinesP() method returns Vec4 array. And x,y,z,w components are not mapped correctly.

This is how I drew lines correctly.

const lines = image.houghLinesP(1, Math.PI/180, 100, 50, 50);
lines.forEach(line => {
    const p1 = new cv.Point(line.y, line.x);
    const p2 = new cv.Point(line.w, line.z);
    image.drawLine(p1, p2, green, 3);
});

If you noticed when I create point object (x,y) compononts are swittched.

To me Mat.houghLinesP() method returns array of array or something else is better instead of Vec4s. It's very confusing.

Auxority commented 5 years ago

Bump, this is still an issue.