How do you save images of detected objects in OpenCV? - c++

I am trying to add "if, then logic" to the opencv face detection code such that if and when a face is detected through a camera or webcam, an image of the detected face is saved to a pre-determined file path on the controller or computer such as C:\Users\Public\Desktop.
I have looked everywhere for examples of anything that can help but I cant find anything.
If anyone knows any codes, research articles, websites, people I can contact, that would be very helpful.
Thanks

The function call that detects the face will most probably contain a boundingRectangle parameter of type vector<Rect>. Use the data present in it to select the Region of Interest(ROI) if a face is detected. This selected ROI can then be saved using this function.
These are the very basics of OpenCV and hence I am not including any code snippets along with my answer.

Based on the detected portion(pending whether you are getting a region or point) from the image, define an roi(if needed). Then copy the roi to new image and then save to path?

Related

Detect multiple 3d shapes in an image

I'm currently learning OpenCV for a project I recently started in, and need to detect 3D boxes (imagine the big plastic boxes maybe 3ft x 2ft x 2ft) in an image. I've used the inRange method to create an image which just had the boxes I'd like to detect in it, but I'm not sure where to go from there. I'd like to get a 3D representation of these boxes back from OpenCV, but I can't figure out how. I've found quite a few tutorials explaining how to do this with just one object (which I have done successfully), but I don't know how I would make this work with multiple boxes in one image.
Thanks!
If you have established a method that works well with one object, you may just go with a divide-and-conquer approach: split your problem into several small ones by dividing your image with multiple boxes into an several images with one object.
Apply an Object Detector to your image. This Tutorial on Object Detection may help you. A quick search for object detection with OpenCV also gave this.
Determine the bounding boxes of the objects (min/max of the x and y-coordinates, maybe add some border margin)
Crop bounding boxes to get single object images
Apply your already working method to the set of single object images
In case of overlap, the cropped images may need some processing to isolate a "main" object. Whether 4. works is then dependent on how robust your method is to occlusions.
I stumbled over your question when looking for object detection. It's been quite a while since you asked, but since this is a public knowledge base a discussion on this topic might still be helpful for others.

Blurry Saved Images of Detected Objects using OpenCV

I have a c++ code that is being run on the Parrot AR.Drone version 2.0 to detect objects, then save images of the detected objects to the controller (computer). As you all may know, the AR.Drone has an 720p High Definition camera. However, the saved images are very blurry. I cannot seem to find any OpenCV function that increases the resolution of the saved images, however I believe the resolution is set to 95/100 by default for OpenCV. Does anyone know of any solution to this problem?
Any input or comment would be helpful.
I think you mean 95/100 of jPEG quality. You can change the third parameter of cv::imwrite like it said in the opencv documentation
cv::imwrite("name.jpg", image, CV_IMWRITE_JPEG_QUALITY=100); //100 instead of default 95
But this method only increase the quality, not the resolution... and there shouldn't be much difference between 95 and 100%.

Capture a specific location of an image using OpenCV

I am trying to organize my trading card collection digitally and am working on building a scanner using ocr to detect the names of my collection.
I need to use a webcam to snap a single image of each card in question. Snapping the image doesn't seem to be to difficult, but I need help determining how to get OpenCV to capture only a specific part of that image for OCR to work with. I'm trying to capture just the text portion of the image so that the artwork on the cards doesn't interfere with the OCR.
If my card will be placed in the same physical location each time, is there a way to get OpenCV to take an image and focus on just the area of the image that I'm interested in.
Thank You
Sour Jack
I am not sure I understand the problem. Do you want to use your OCR algorithm always on the same portion of the snapshot? If so, you can try something like:
roi = img[y:y+height, x:x+width]
There is more information here: http://answers.opencv.org/question/29260/how-to-save-a-rectangular-roi/

Object Identification using opencv in a given image

in my project i want to identify objects and then detect what they are(water bottle, ball, etc).
I thought of identifying the objects in the image and then match that object with a object database using SURF method.
But the problem is to identify the whether my image has a object or not and how many objects are there.
I did some search and find out about "contours", a way to track shapes. I want to know whether "contours" will help to solve my problem or any other way to solve this.
Thanks.
First, for identifying the objects you can also use BoW, cascade classifier or latent svm.
Once you have an object classifier, you can use the sliding window approach to search for the object in the image. Take a look at the cascade classifier for an example of the sliding window approach.
EDIT: here's a post blog I wrote about BoW theory and packages in Matlab and openCV
http://gilscvblog.wordpress.com/2013/08/23/bag-of-words-models-for-visual-categorization/

stitching aerial images to create a map

I am working on a project to stitch together around 400 high resolution aerial images around 36000x2600 to create a map. I am currently using OpenCV and so far I have obtained the match points between the images. Now I am at a lost in figuring out how to get the matrix transformation of the images so I can begin the stitching process. I have absolutely no background in working with images nor graphics so this is a first time for me. Can I get some advice on how I would approach this?
The images that I received also came with a data sheet showing longitude, latitude, airplane wing angle, altitude, etc. of each image. I am unsure how accurate these data are, but I am wondering if I can use these information to perform the proper matrix transformation that I need.
Thanks
Do you want to understand the math behind the process or just have an superficial idea of whats going on and just use it?
The regular term for "image snitching" is image alignment. Feed google with it and you'll find tons of sources.
For example, here.
Best regards,
zhengtonic
In recent opencv 2.3 release...they implemented a whole process of image stitching. Maybe it is worth looking at.