Extract object and save it as an image.png using c++

asked 2019-11-19 11:13:41 -0500

zakaziko gravatar image

HI Forum , Actually I work on a car detection project at real time, when I launch the camera I want to make a screenshot (.png) for any car and save it in a path, which means i need a function in opencv that does the screenshot of just a car detected (not all windows).

Suppose you have the following image:

image description

Now i want to extract to individual images each of the independent cars, like this for example:

image description

NB: i have a function can be detect object and draw a contour of each object is FeatureTracker() , i would use it for extracting image and save it in path/image.png

Thanks in advice

edit retag flag offensive close merge delete

Comments

You already have the car detection routine ? has bounding boxes ? you can copy the bounding box ROI and save it .

Ziri gravatar imageZiri ( 2019-11-21 03:07:43 -0500 )edit

Thanks for your reply Ziri , could you please take look a few minute at this project https://github.com/JdeRobot/traffic-m... ,, i want to add this function here.

zakaziko gravatar imagezakaziko ( 2019-11-21 04:11:03 -0500 )edit

If you've successfully ran that code check blob.h and track where void calculate_blob_center() or get_rect() are called ;

Use Their returned coordinates to do something like this :

SrcImage = imread(""); Rect Car_roi = Rect(leftCornerX, leftCornerY, BoxWidth, BoxHeight); Mat Car_roi_image = SrcImage (Car_roi );

Ziri gravatar imageZiri ( 2019-11-21 18:54:26 -0500 )edit