Author Message

<  beginners  ~  scaling contour

PostPosted: 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.


Offline Profile
PostPosted: Thu Oct 29, 2009 10:59 am
User avatarJoined: 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
Offline Profile
PostPosted: 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


Offline Profile
PostPosted: Thu Oct 29, 2009 6:00 pm
User avatarJoined: 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
Offline Profile
PostPosted: 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;
}
}


Offline Profile
PostPosted: Sun Nov 01, 2009 4:27 pm
User avatarJoined: 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
Offline Profile
PostPosted: 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.


Offline Profile
PostPosted: Wed Nov 11, 2009 12:55 pm
User avatarJoined: 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.
Offline Profile

Display posts from previous:  Sort by:

All times are UTC
Page 1 of 1
8 posts
Users browsing this forum: Google [Bot] and 2 guests
Search for:
Post new topic  Reply to topic
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
cron