Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapper for approxPolyDP #203

Open
setphen opened this issue Nov 7, 2016 · 2 comments
Open

Wrapper for approxPolyDP #203

setphen opened this issue Nov 7, 2016 · 2 comments

Comments

@setphen
Copy link

setphen commented Nov 7, 2016

I really want to utilize the polygon approximation function approxPolyDP, which is part of opencv/imgproc
opencv doc reference here

I don't have enough knowledge currently to write the wrapper myself - Are there significant difficulties in wrapping this feature? If I can get it working, I will see if I can make a pull request.

@setphen
Copy link
Author

setphen commented Nov 7, 2016

I found a snippet here which describes the implementation
https://forum.openframeworks.cc/t/contour-polyline-simplification/4461

But I change a line in the block

result = cvApproxPoly  
    (  
        &contour,  
        sizeof( CvContour ),  
        storage,  
        CV_POLY_APPROX_DP,  
        cvContourPerimeter( &contour ) * tolerance,  
        0  
    ); 

to

result = cvApproxPoly  
    (  
        &contour,  
        sizeof( CvContour ),  
        storage,  
        CV_POLY_APPROX_DP,  
        tolerance,  
        0  
    ); 

in order to have a consistent tolerance (epsilon, according the algorithm) instead of adjusting it based on the contour perimeter length. This keeps simplified vertices more consistent and defined, rather than jumping around.

@avilleret
Copy link
Contributor

I'm not sure a wrapper is necessary here, if you need to use the function, just do it like your code snippet does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants