This OpenCV tutorial is a very simple code example of GPU Cuda optical flow in OpenCV written in c++. The configuration of the project, code, and explanation are included for farneback Optical Flow method. Farneback algorithm is a dense method that is used to process all the pixels in the given image. The dense methods are slower but more accurate as all the pixels of the image are processed. In the following example, I am displaying just a few pixes based on a grid. I am not displaying all the pixes. In the opposite to dense method the sparse method like Lucas Kanade using just a selected subset of pixels. They are faster. Both methods have specific applications. Lucas-Kanade is widely used in tracking. The farneback can be used for the analysis of more complex movement in image scene and furder segmentation based on these changes. As dense methods are slightly slower, the GPU and Cuda implementation can lead to great performance improvements to calculate optical flow for all pixels o
Face detection and Transparent image in opencv
Face detection Opencv C++ tutorial about how to replace the face with mask. Easy steps to achieve results like many popular applications that just enhance your face. Code is just part that we already have available video reader written in opencv and just apply the face detection part with mask over the detected face.
Pixel by pixel color value filtering
Let me explain how to add a transparent mask over the ROI in a video sequence.
This image of the anonymous mask has a white background. Add this image to the selected area pixel by pixel with following condition. Add mask to the background video if the color of the mask is black. It s really simple idea. Image could be added over the roi in different way, but in the case you want to filter by pixel color value. This is example for you.
Code Opencv Tutorial
Just remember you need to at least figure out how to load the image or video into the IMG source mat.
//Normal face detection by haar cascade in opencv
CascadeClassifier faceDetector;
bool loaded1 = faceDetector.load("facehaarcascade.xml");
Mat original; img.copyTo(original);
std::vector faces;
cvtColor(img, img, CV_BGR2GRAY);
equalizeHist(img, img);
detectorBody.detectMultiScale(img, faces, 1.1, 2, 0 | 1, Size(40, 40), Size(400,400 ));
Mat Original;
//Read the anonymous mask
Mat imageMask = imread("MASK.png", 1);
// Draw the mask over all rectangles
for( size_t i = 0; i < faces.size(); i++ )
{
int xx =0, yy =0;
// Just iterate in face region pixel by pixel
for(int x = faces[i].x; x < faces[i].x+faces[i].width; x++)
{
for (int y = faces[i].y; y < faces[i].y+faces[i].height; y++)
{
//This is core of the trick.
// Copy Mask to Original image If the 0 chan
// Proper condition is over all color channels
// imageMask.at(xx,yy)[0] < 10
// imageMask.at(xx,yy)[1] < 10
// imageMask.at(xx,yy)[2] < 10
// Black Color(0,0,0)
if (imageMask.at(xx,yy)[0] < 10)
{
// Copy to original image on (y,x) places the pixel of xx,yy mask
Original.at(y,x)[0] = imageMask .at(xx,yy)[0];
Original.at(y,x)[1] = imageMask .at(xx,yy)[1];
Original.at(y,x)[2] = imageMask .at(xx,yy)[2];
}
// Iterate in mask x
xx =xx+1;
}
// iterate next row of imageMask
xx = 0;
yy =yy+1;
}
}
so interesting! can i have full source code bro? :D
ReplyDeleteThis is almost full source code! You only need capture video from video file or web camera. Put this image or image sequence into Mat Original; and apply the mask (Code is here). I am sorry this is more than enough. You only need to video input loop.
ReplyDeletejava codings with examples
ReplyDeleteI am sorry this is more than enough. You only need to video input loop.
ReplyDeleteโกลเด้นสล็อต
goldenslot
Great work! I want to do something like placing image on the eyes. How can I get it done? Any ideas? I'd really love to know. Thank you! :D
ReplyDeletecreativity of writer is purely impressive. It has touched to the level of expertise with his writing. Everything is up to the mark. Written perfectly and I can use such information for my coming assignment.ทำจมูก
ReplyDeleteVideos and articles are good and useful.
ReplyDeletegoldenslot
This comment has been removed by the author.
ReplyDeleteVery cool.
ReplyDeletegclub มือถือ
gclub iphone
gclub android
It is a subject that is novel and very interesting to follow.
ReplyDeleteviva9988 holiday
goldenslot
ReplyDeleteโกลเด้นสล็อต
สล็อตออนไลน์
โปรโมชั่นใหม่ “แจกโบนัส สูงสุดทันที 1,000 บาท”
ReplyDeletegclub online โปรโมชั่น แบบครบวงจรที่คอยอัพเดทข่าวสารเกี่ยวกับโปรโมชั่น จีคลับ บาคาร่าออนไลน์ สล็อตออนไลน์ ตลอดทั้ง 24 ชั่วโมง เพื่อให้ท่านได้สามารถเข้าร่วมสนุกไปกับเกมออนไลน์ของเราได้ตลอดเวลาโปรโมชั่นสำหรับสมาชิก Premium, VIP ที่แจกโบนัสให้สูงที่สุด 10% และโปรโมชั่นแบบรายวัน สำหรับคำขอบคุณที่มอบให้กับ โปรโมชั่น gclub