| Author |
Message |
|
|
matias
|
Posted: Thu Oct 29, 2009 12:30 am |
|
|
| Joined: Fri May 29, 2009 4:37 pmPosts: 50 |
hello , im new with openframeworks , i been experimenting with countour interaction ....my questions are :which is the best way of scaling a countour? im using the vector with the contour data and i would like to scale this data. my question is: if i use : contourFinder.draw(20,20, 640, 480);
i can scale the countour in the way how it looks, but does it also scale the vector data?
and my second question is : if i draw each blob individually as im doing for using the vector data i cant use the scale , ex:
for (int j = 0; j < contourFinder.nBlobs; j++){ contourFinder.blobs[j].draw(20, 20); }
in this example 20, 20 just define the position but i cannot scale like contourFinder.draw(20,20, 640, 480); where 640 , 480 define the scale.
how can i scale? OR maybe is a better idea to draw a big video instead of drawing a small video and scaling the countour data, which is better in terms of cpu process?
many thanks
Matias.
|
|
Top
|
|
|
damian
|
Posted: Thu Oct 29, 2009 10:59 am |
|
|
Joined: Fri Jul 04, 2008 9:31 amPosts: 414Location: Vienna, Austria |
hi Matias,
the draw() function does not scale the underlying data, it just scales it when it is drawn.
in fact, the 640*480 doesn't define a 'scale', but rather it says 'figure out a scale to draw the contours in a 640*480 rectangle, and draw at that scale.' if the input image that the contours were taken from was a 320*240 image, then 640*480 will draw at xScale = 2 and yScale = 2.
in terms of processing power, the cost of scaling a bunch of vectors is so much smaller than the cost of running through the image looking for the vectors in the first place, that it really doesn't matter which way you do it.
_________________ damian stewart | skype: damiansnz | damian [at] frey [dot] co [dot] nz
frey | live art with machines | http://www.frey.co.nz |
|
|
Top
|
|
|
matias
|
Posted: Thu Oct 29, 2009 3:58 pm |
|
|
| Joined: Fri May 29, 2009 4:37 pmPosts: 50 |
damian wrote: hi Matias,
the draw() function does not scale the underlying data, it just scales it when it is drawn.
in fact, the 640*480 doesn't define a 'scale', but rather it says 'figure out a scale to draw the contours in a 640*480 rectangle, and draw at that scale.' if the input image that the contours were taken from was a 320*240 image, then 640*480 will draw at xScale = 2 and yScale = 2.
in terms of processing power, the cost of scaling a bunch of vectors is so much smaller than the cost of running through the image looking for the vectors in the first place, that it really doesn't matter which way you do it. thanks, but how can i scale the vector? is there an automatic way of scale the vector pts? or do i need to iterate all over the vector ? bye
|
|
Top
|
|
|
damian
|
Posted: Thu Oct 29, 2009 6:00 pm |
|
|
Joined: Fri Jul 04, 2008 9:31 amPosts: 414Location: Vienna, Austria |
yeah, you need to iterate over all of them as far as i know..
_________________ damian stewart | skype: damiansnz | damian [at] frey [dot] co [dot] nz
frey | live art with machines | http://www.frey.co.nz |
|
|
Top
|
|
|
matias
|
Posted: Fri Oct 30, 2009 9:42 pm |
|
|
| Joined: Fri May 29, 2009 4:37 pmPosts: 50 |
damian wrote: yeah, you need to iterate over all of them as far as i know.. hi , ive tried the following code for scaling the vector of each blob, and now im getting a wierd behaivor in my programs, now i have lot of copies of the my contourn , is there anything im mising? or any idea of what a im doing wrong? thanks in advance for (int i = 0; i < contourFinder.nBlobs; i++){ for(int j = 0; j < contourFinder.blobs[i].pts.size(); j++) { contourFinder.blobs[i].pts[j] = contourFinder.blobs[i].pts[j] * 2; } }
|
|
Top
|
|
|
damian
|
Posted: Sun Nov 01, 2009 4:27 pm |
|
|
Joined: Fri Jul 04, 2008 9:31 amPosts: 414Location: Vienna, Austria |
could you be a little more specific - what 'weird behaviour' are you getting?
_________________ damian stewart | skype: damiansnz | damian [at] frey [dot] co [dot] nz
frey | live art with machines | http://www.frey.co.nz |
|
|
Top
|
|
|
matias
|
Posted: Tue Nov 03, 2009 7:51 pm |
|
|
| Joined: Fri May 29, 2009 4:37 pmPosts: 50 |
damian wrote: could you be a little more specific - what 'weird behaviour' are you getting? The contours appears repeated a lot of times each one scaled by 2.
|
|
Top
|
|
|
jeraman
|
Posted: Wed Nov 11, 2009 12:55 pm |
|
|
Joined: Tue Mar 17, 2009 8:43 pmPosts: 15Location: Recife, Brazil |
i already had this problem... in my case i just used contour's draw(int, int, int, int) and everything was ok. what you can do in this case is open ofxCvContourFinder.cpp file inside ofxOpenCv addon directory and check how he/she iterates over the list... so you could do the same to scale them.
_________________ jeraman
life is random. live a shuffle life. |
|
|
Top
|
|
|
|