Extract object and save it as an image.png using c++
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:
Now i want to extract to individual images each of the independent cars, like this for example:
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
You already have the car detection routine ? has bounding boxes ? you can copy the bounding box ROI and save it .
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.
If you've successfully ran that code check blob.h and track where
void calculate_blob_center()
orget_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 );
Hi @Ziri i'm sorry for the delay , i tried follow your answer but not work , I tried to add the function imwrite("/path/image",output) in file
viewgtk.cpp
line 312 , it's work but the result of image is blur like this image file:///home/bpros/Desktop/04-12-2019%2018-55-40.png , any idea to improve quality of images + remove the blur ,keep reminder!! @Ziri