Ask Your Question
0

How should I maintain the color of Drawing?

asked 2013-09-03 08:19:54 -0600

zawpai gravatar image

updated 2013-09-03 21:10:21 -0600

Hi All,

I would like to get some suggestion from you. Currently, I have two problems.

1.) I have a live image from camera and I want to draw a rectangle every one second until to 9 rectangles.But, I don't know how to maintain all previous rectangle?

2.) If I use one image to save my drawing and overlay with image from camera. It will make system will be very slow. If I change illumination of camera, the color of rectangles should not be effected while doing overlay process.

This is my real application. Let machine to move a position and then find the object. When the object is found, system will draw a rectangle. image description I only want to do display same as current system.

Best regards

edit retag flag offensive close merge delete

Comments

1

why not redraw them on every frame ? it's not expensive at all .

also, keeping an overlay img in memory should be fairly cheap.

berak gravatar imageberak ( 2013-09-03 08:28:06 -0600 )edit

Could you show a picture of how this should look like?

Moster gravatar imageMoster ( 2013-09-03 08:28:50 -0600 )edit

Like @berak said, store the drawed rectangles into a vector element, and redraw the rectangles at each frame, which isn't expensive at all :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-03 09:30:48 -0600 )edit

1.) I save all my drawing with "IplImage", but I am not sure whether it is same as img in memory. Then, I overlay two images pixels per pixels. It will slow down system performance. 2.) How should I upload a picture in this forum? I don't know how to do that. 3.) Can you give me some reference links to store all my drawing into a vector element? I am quite new with OpenCV. It's be better to get with low version of openCV.

This is the flow how "Commercial Image Library" does. a.) They save image from camera in their buffer. b.) They create a overlay buffer to store all drawing. c.) Finally, they will display together. So, they can draw any where. Display for drawing will not effect when the illumination is changed. Refresh process is also very first. I want to do same as that feature.

zawpai gravatar imagezawpai ( 2013-09-03 20:47:36 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2013-09-04 00:49:49 -0600

Moster gravatar image

updated 2013-09-04 03:21:03 -0600

First calculate your rectangles and save them in a Array (since its c only) Since you want to use opencv 1.0, you need to save 2 opposite points for every rectangle (upper left and lower right for example)

CvPoint points1[9];
CvPoint points2[9];

calculate your Rectangles points and add them to the arrays with points1[i] = cvPoint(x,y) (upper left) and point2[i] = cvPoint(x,y) (lower right).
Make sure you have an iterator variable i.

Then draw the rectangles on your image:

for(int j = 0; j < i; j++){
    cvRectangle(img, points1[j], points2[j], color, thickness, 8, 0);
}

This should definitely not take long.

edit flag offensive delete link more

Comments

Thanks for your coding. Our project is using VC6.0. So,I can't use the library of higher version of openCV. Is it possible to do with OpenCV1.0?

zawpai gravatar imagezawpai ( 2013-09-04 02:10:14 -0600 )edit
1

Changed it to some c style that should work with opencv 1.0

Moster gravatar imageMoster ( 2013-09-04 03:22:12 -0600 )edit
1

zawpai, you won't get happy like that in the long run.

berak gravatar imageberak ( 2013-09-04 03:26:37 -0600 )edit

Is there any reason why you wouldn't update your system to be up to date and possible to run under vc10?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-04 05:01:27 -0600 )edit

Thanks for all of suggestions. I will try to complete my current project first. For next version, I will try to use vc10 because my project time line is very near and I am not so familiar with VC environment.

zawpai gravatar imagezawpai ( 2013-09-04 19:41:02 -0600 )edit
0

answered 2013-09-03 13:22:41 -0600

xaffeine gravatar image

Just keep a vector of rectangles that you would like to draw. Drawing 9 rectangles per frame is not going to cause performance issues.

edit flag offensive delete link more

Comments

Next time read comments :) the same suggestion has been given twice ...

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-03 13:38:54 -0600 )edit

Question Tools

Stats

Asked: 2013-09-03 08:19:54 -0600

Seen: 221 times

Last updated: Sep 04 '13