Extract object from black background OpenCV C++ - c++

First you have to know that I work with OpenCV in C++ in Visual Studio.
I have a picture like : Original image
I want to create a new picture of the hand but with a lot less of black bacground.
So the final image should look like this : Final Image
I know there are some OpenCv functions that could help me but I have really trouble to implement the algorithm because OpenCv can't be used in Debug Mode so it hard to check what I am doing.
Have anyone any idea how to proceed ?
Thanks you very much.

Find contour, find bounding rectangle, crop.
Here is example of finding bounding box: example

Related

Hand rectangle detection with OpenPose

I'm using openpose, and I have no clue of how to start this task.
I need to draw a rectangle over the people's hand (not the pose of the fingers, just the rectangle), using the skeleton estimation that open pose provides, but I don't really have experience with this framework, and I'm having a hard time understanding the openpose code, so I don't know if somebody could give any advice or clue about how to achieve this task, might be with the right direction I could get it done.
Any comment is welcome, thanks in advance for any help.
It is not easy to start at first, you should read more from the dlib home page before starting. After that you could follow my below suggestion to achieve your desire.
Download the source code from github Dlib on github
Implement by the function void work(TDatums& tDatums) in the file /include/openpose/pose/wPoseExtractor.hpp
Get the keypoints and image as below code
auto &ProceedData = (*tDatums)[0];
Array keypoints = ProceedData.poseKeypoints;
Mat proceedImage = ProceedData.cvOutputData;
You can draw your own image.

How to extract the finger vein clearly from camera or picture by using opencv

I'm using Opencv extract the finger vein from a camera, first I use the GaussianBlur to smooth the image and then use the adpateThreshold to get the binary image, but the result isn't good, because the camera has a lot of salt noise and it made each frame are difference(for the brightness), the binary image is very unstable(I also tried the medianBlur but the result isn't good too), so I think to extract the vein from camera can't simply use the threshold method. could anyone give me some suggestion about how to extract a clear and stable finger vein by using opencv?
thanks a lot.
Photo here

C++: Creating Polygons from images' transparency

Alright guys..
I'm at a loss here. I've been trying to code an image to polygon converter to no avail, it's really bugging me. It's supposed to create a polygon from the transparency of an image (the non transparent part is the polygon). I've seen programs that do it, but they were closed-source and really expensive. It's not just edge-detection, it's polygon generalization and hole-detection as well, all this in a Box2D compatible, triangulated polygon.
Please hand me some tips on this, or a library name, or an algorithm or something..
Thanks!
I suggest looking at the openCV library. It has several useful algorithms and tools for
image processing. I think you can accomplish your goal with it.
Good luck.

Detect object stored in Mat image opencv

I'm trying to detect an object using opencv and Visual Studio Ultimate using C++. I'm having problems concerning cv::Mat, I cannot find any example of object detection with that kind of variable but just with IplImage. I tried to use an IplImage code and convert it to Mat, but it didn't work. But i don not want to use IplImage, my first part of code is in Mat and I want to keep using it.
What I'm trying to actually do is to detect the BIGGEST rectangle in the image stored from the cam, after thresholding it.
I have already done the threshold part and it's ok, it works and i can se my object (in white) moving in a black background.
Could someone help me with the tracking part? I have seen on the net some blob filtering solutions but they were way too difficult for me! If you can come up with an easy one it would be better.
thank you!
cv::Mat is the new image class in opencv. I think the most algorithms still use IplImage. For this reason I have asked times ago the following:
openCV mixing IplImage with cv::Mat
For recognition of objects I would say watch the cvMatchTemplate function of opencv. There is also the mat version cv::matchTemplate. There are also other object recognition methods but they are a bit more difficult to implement ;)
I dont know if I maybe understood your other question right but I think you wannt to recognze rectangle in your image. Maybe watch this tutorial:
http://docs.opencv.org/trunk/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html
I don t know any standard algorithm for rectangles maybe you will need to code it yourself
cv::Mat encapsulate the lower level IplImage and other formats. Regard detection, there is a sample that you could find useful: squares. I googled for it, and found also this other question, that's more recent and could be of interest to you.

is there any image library can cut the white edge of a picture?

I'd like to know if there are any image librarys can cut the white edge of a picture automatically,
for example:
cut The Wonderful Wizard of Oz.png
to cutted.png
opensource would be very handy
Thanks advance for your help.
Best regards,
hb
Any popular image library should be able to get the pixel value from an image. You can probably just determine which area is white and then cut that off using the library and save the result.
Check out ImageMagick.