Ask Your Question
1

FindContours Precsision

asked 2013-11-18 19:35:28 -0600

Phando gravatar image

updated 2020-11-06 05:31:28 -0600

Hey All, I am on iOS and trying to use FindContours to extract nice smooth lines from my images. Unfortunately it seems all the output from FindContrours is integer data. Is there something special I need to do in order to get float values from findContours? For all intents and purposes, you can assume my code looks just like the demo code: This Sample

Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-11-19 01:45:33 -0600

Michael Burdinov gravatar image

Input is an integer data (an image) and so the output is integer data as well (and this is the most precise answer). In general, in computer vision you are not getting 'smooth' output without performing additional processing. In your case I would recommend you to start from providing different flags to findContours. Instead of CV_CHAIN_APPROX_SIMPLE try using CV_CHAIN_APPROX_TC89_L1. This will perform some polygon simplification, i.e. it will 'smooth' contours a little in exchange for precision. Or you can perform simplification by using approxPolyDP after your call to findContours.

edit flag offensive delete link more

Comments

Thanks for the quick response, Input quality equals output quality makes sense. The findContours function only accepts binary data, so messing with my images pre findContours has proven moot. I have changed my findContours method to CV_CHAIN_APPROX_TC89_L1 and tried calls to approxPolyDP with various epsilon values and still I am only seeing integers in my contours vector. Contours is a 2D vector of cvPoints. The only way I am able to see floats is to calculate my own cubic bezier control points. Even then the points generated from opencv are integers. Is there any way to get opencv to generate float values for contours?

Phando gravatar imagePhando ( 2013-11-19 12:53:58 -0600 )edit

Hmm, no. I don't remember anything that creates contours of floating points.

Michael Burdinov gravatar imageMichael Burdinov ( 2013-11-20 00:40:45 -0600 )edit

Without floats findContours is still kinda awesome. Thanks for your help.

Phando gravatar imagePhando ( 2013-11-20 11:48:27 -0600 )edit

You are welcome

Michael Burdinov gravatar imageMichael Burdinov ( 2013-11-21 00:52:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-11-18 19:35:28 -0600

Seen: 3,583 times

Last updated: Nov 19 '13