OpenCV Q&A Forum - RSS feed answersenCopyright <a href="">OpenCV foundation</a>, 2012-2018.Wed, 27 Mar 2019 06:45:03 -0500human detection in water hi everyone, I'm Kanva. I'm new to openCV-Python. I'm trying to capture images automatically when a person is drowning in a swimming pool. I tried on my own but I cannot succeed. I request your help at any development of this idea. Once human presence is detected and captured in water is enough. kanvaWed, 27 Mar 2019 06:45:03 -0500 can I divide an image into two specific polygons? Hi , I am not sure that the question has been asked or not. I have an image shown in first picture. And i detect humans in the picture. But i want to find where the detected humans located. I create two or more polygons in an image shown the second picture and need to find regions of detected humans. For example, suppose i have 5 detected humans in the image and then i need to find how many of them is in region 1 and how many of them is in region 2. I have coordinates of detected humans, and i developed an algorithm in it i compare coordinates of the regions and detected humans' coordinates. But i wonder i can use a different approach in such scenario. I would be appreciated if any help . ![image description](/upfiles/15447841173292475.png) ![image description](/upfiles/1544784134189477.png)elnuraFri, 14 Dec 2018 04:59:17 -0600 detection in android studio using opencv hi can i detect total faces from an image or from an imageview in android using opencv ? Thanks Samir MishraSamir MishraThu, 04 Jan 2018 23:34:32 -0600 Detection Hi i want to detect Human Leg. what is the best method for detecting Human Leg. Thank youLafiSun, 03 Jul 2016 23:06:32 -0500 source person detection there I'm looking for an open source code of a Human/person detection using depth information only. I need only a simple detection of the person in depth images without skeletal tracking or something like that. Anyone had already worked on this or have some sources?ROSpioneerFri, 08 Apr 2016 05:00:21 -0500 do I segment the actual human body shape from an image? single image of a dressed human (say wearing pant and shirt) with clear and plain background, I need to draw outline of his body shape for only that particular pose given in the image. Can anyone suggest any approach?nanosaanSun, 20 Mar 2016 23:36:46 -0500 to detect human body parts in real time? am currently working on human pose recognition. I want to have bounding boxes over the body parts like hands, legs, torso etc. So that it can be measured.Avinashs95Fri, 04 Mar 2016 01:52:50 -0600 to detect human using findcontours based on the human shape? hi guys, I wanna ask how to detecting humans or pedestrians on blob (findcontours)? I've try to learn how to detecting any object on the frame using findcontours() like this: #include"stdafx.h" #include<vector> #include<iostream> #include<opencv2/opencv.hpp> #include<opencv2/core/core.hpp> #include<opencv2/imgproc/imgproc.hpp> #include<opencv2/highgui/highgui.hpp> int main(int argc, char *argv[]) { cv::Mat frame; cv::Mat fg; cv::Mat blurred; cv::Mat thresholded; cv::Mat thresholded2; cv::Mat result; cv::Mat bgmodel; cv::namedWindow("Frame"); cv::namedWindow("Background Model" //,CV_WINDOW_NORMAL ); //cv::resizeWindow("Background Model",400,300); cv::namedWindow("Blob" //,CV_WINDOW_NORMAL ); //cv::resizeWindow("Blob",400,300); cv::VideoCapture cap("campus3.avi"); cv::BackgroundSubtractorMOG2 bgs; bgs.nmixtures = 3; bgs.history = 1000; bgs.varThresholdGen = 15; bgs.bShadowDetection = true; bgs.nShadowDetection = 0; bgs.fTau = 0.5; std::vector<std::vector<cv::Point>> contours; for(;;) { cap >> frame; cv::GaussianBlur(frame,blurred,cv::Size(3,3),0,0,cv::BORDER_DEFAULT); bgs.operator()(blurred,fg); bgs.getBackgroundImage(bgmodel); cv::threshold(fg,thresholded,70.0f,255,CV_THRESH_BINARY); cv::threshold(fg,thresholded2,70.0f,255,CV_THRESH_BINARY); cv::Mat elementCLOSE(5,5,CV_8U,cv::Scalar(1)); cv::morphologyEx(thresholded,thresholded,cv::MORPH_CLOSE,elementCLOSE); cv::morphologyEx(thresholded2,thresholded2,cv::MORPH_CLOSE,elementCLOSE); cv::findContours(thresholded,contours,CV_RETR_CCOMP,CV_CHAIN_APPROX_SIMPLE); cv::cvtColor(thresholded2,result,CV_GRAY2RGB); int cmin = 50; int cmax = 1000; std::vector<std::vector<cv::Point>>::iterator itc=contours.begin(); while (itc!=contours.end()) { if (itc->size() > cmin && itc->size() < cmax){ std::vector<cv::Point> pts = *itc; cv::Mat pointsMatrix = cv::Mat(pts); cv::Scalar color( 0, 255, 0 ); cv::Rect r0= cv::boundingRect(pointsMatrix); cv::rectangle(frame,r0,color,2); ++itc; }else{++itc;} } cv::imshow("Frame",frame); cv::imshow("Background Model",bgmodel); cv::imshow("Blob",result); if(cv::waitKey(30) >= 0) break; } return 0; } and now I wanna know how to detect humans? am I need to use hog? or haar? if yes I need to use them, how to use them? any tutorials to learn how to use it? because I'm so curious! and it's so much fun when I learn OpenCV! so addictive! :)) anyway I'll appreciate any help here, thanks. :)ShabanMon, 10 Jun 2013 21:24:58 -0500 human detection dataset Hi, I have a little question concerning opencv implementation and maybe someone here knows the answer. I’m using the HOGDescriptor class for human detection and I’d like to know how was trained the openCV SVM for human body detection: is it with the INRIA dataset ( or something else? I’ve searched on the opencv documentation and stackoverflow but I haven’t found what I was looking for. The problematic behind this question is that I don't get good detection results with the OpenCV dataset and I'd like to know if it could be a good idea to try to train my own SVM with another dataset.cylixMon, 14 Sep 2015 03:00:58 -0500 Point Distance![image description](/upfiles/14366101874043777.jpg) In Picture 1 Point Reference to find distance between black line. I want to measure the black line. please share idea or code for me. Help me..................lsewataSat, 11 Jul 2015 05:28:33 -0500 do i detect a any dog and ignore any human? how do i detect a any dog and ignore any human? I want to use live video capture. I guess this is a shape recognition problem more than a face recognition one but does anyone have any thoughts on the idea.dazza000Wed, 29 Apr 2015 05:00:44 -0500 human detection - ARM gnueabi, I am trying to implement human detection on an IP camera (system linux gnueabi). I have seen that there are solutions with Open CV algorithm for human or face detection in embedded systems, in recent articles. My camera has 45Mo of RAM, and the CPU has the following characteristics : Processor : FA626TE rev 1 (v5l) BogoMIPS : 539.03 Features : swp half CPU implementer : 0x66 CPU architecture : 5TE I am limited to 2Mo of utilisation of the RAM, beacause of other applications. And I have the constraint of real-time image processing. Do anyone think it is possible to realize that with openCV library on such a camera ? Thank you in advance to any one who may be able to give me some tips :)ltrubuilTue, 28 Apr 2015 04:09:03 -0500 aerial human detection? guys... I am trying to detect human individuals from aerial photos, but i am having a hard time finding a smart method to make it possible. It should be robust such that all other things should be ignored, and only trigger when a human appear, how would you do that using openCV? or what method would you use. It should be able to detect people out in the sea, but at the same time ignore other things such as ships, fish and so on. 215Thu, 02 Apr 2015 13:04:09 -0500 crowd detection behavior want to develop abnormal crowd detection, what's the stages i have do, i have done optical flow?ddm67Wed, 07 Jan 2015 09:43:29 -0600 to detect individual body parts in an image -- I would like to find a way to identify individual body part limbs in an image (ie such as Forearm or lower leg). The only problem being that I can't seem to find a reasonable feature detector or classifier to detect this in a rotation and scale invariant way (as is needed by objects such as forearms). One solution I have tried so far to no avail is HOG detection for forearm identification. I used a 32x32 window with a variety of different input parameters but was never able to to retrieve accurate detection in images. Information: -- Lets focus on forearms for this discussion. A forearm can have multiple orientations, the primary distinct features probably being its contour edges. It is possible to have images of forearms that are pointing in any direction in an image, thus the complexity. So far I have done some in depth research on using HOG descriptors to solve this problem, but I am finding that the variety of poses produced by forearms in my positives training set is producing very low detection scores in actual images. I suspect the issue is that the gradients produced by each positive image do not produce very consistent results when saved into the Histogram. I have reviewed many research papers on the topic trying to resolve or improve this, including the original from Dalal & Triggs [Link]: It also seems that the assumptions made for detecting whole humans do not necessary apply to detecting individual features (particularly the assumption that all humans are standing up seems to suggest HOG is not a good route for rotation invariant detection like that of forearms). Note: -- If possible, I would like to steer clear of any non-free solutions such as those pertaining to Sift, Surf, or Haar. I have also asked the same question on Stack Overflow: Question: -- What is a good solution to detecting rotation and scale invariant objects such as human limbs in an image? Particularly for this example, what would be a good solution to detecting all orientations of forearms in an image?BuckSun, 29 Jun 2014 14:24:11 -0500 image of human arm want to get a skeletal image of a human arm. The person whose arm is in consideration is a cricket bowler. So can anyone spill some ideas and algorithms for this task. dextermorganWed, 04 Jun 2014 08:55:02 -0500 to improve the accuracy of human detection with HOG?, everyone. I have a code for human detection. But it works not good enough as my expectation. How can I improve the accuracy by modifying the code? Thanks for helping. Here are my code: #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <opencv2\opencv.hpp> #include <stdio.h> #include <stdlib.h> #include <opencv\cv.h> #include <opencv\highgui.h> #include <opencv\cxcore.h> using namespace std; using namespace cv; int main (int argc, const char * argv[]) { CvCapture *capture = cvCaptureFromFile("D:video3.mp4"); if(!capture) { printf("!!! cvCaptureFromFile failed (file not found?)\n"); return -1; } IplImage *frame = NULL; Mat img; HOGDescriptor hog; hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); namedWindow("video capture", CV_WINDOW_AUTOSIZE); int a = 3; while (true) { frame = cvQueryFrame(capture); if (!frame) { printf("!!! cvQueryFrame failed: no frame\n"); break; } a++; img = frame; if(a == 4) { a = 0; if (! { continue; } vector<Rect> found, found_filtered; hog.detectMultiScale(img, found, 0, Size(8,8), Size(0,0), 1.05, 2); size_t i, j; for (i=0; i<found.size(); i++) { Rect r = found[i]; for (j=0; j<found.size(); j++) if (j!=i && (r & found[j])==r) { break; } if (j==found.size()) { found_filtered.push_back(r); } } cout<< "numbers of rectangle：" <<found.size()<<endl; cout<< "numbers of rectangle after filtered：" <<found_filtered.size()<<endl; for (i=0; i<found_filtered.size(); i++) { Rect r = found_filtered[i]; r.x += cvRound(r.width*0.1); r.width = cvRound(r.width*0.8); r.y += cvRound(r.height*0.06); r.height = cvRound(r.height*0.9); rectangle(img,,, cv::Scalar(0,255,0), 2); } imshow("video capture", img); if (waitKey(20) >= 0) { break; } } } return 0; }h7654567Mon, 13 Jan 2014 08:45:59 -0600 body detection with c+, I am new with OpenCV. I wrote a code for human full body detection, but it works not very well. Sometimes when I stay infront of camera, it does not recognise me. Maybe I done some mistakes in my code. I hope You understand me. #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include <iostream> #include <stdio.h> using namespace std; using namespace cv; /** Function Headers */ void detectAndDisplay( Mat frame ); /** Global variables */ String body_cascade_name = "haarcascade_fullbody.xml"; CascadeClassifier body_cascade; string window_name = "Capture - Face detection"; RNG rng(12345); /** @function main */ int main( int argc, const char** argv ) { CvCapture* capture; Mat frame; //-- 1. Load the cascades if( !body_cascade.load( body_cascade_name ) ) { printf("--(!)Error loading\n"); return -1; }; //-- 2. Read the video stream capture = cvCaptureFromCAM( -1 ); cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, 180 ); cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 180 ); if( capture ) { while( true ) { frame = cvQueryFrame( capture ); //-- 3. Apply the classifier to the frame if( !frame.empty() ) { detectAndDisplay( frame ); } else { printf(" --(!) No captured frame -- Break!"); break; } int c = waitKey(100); if( (char)c == 'c' ) { break; } } } return 0; } /** @function detectAndDisplay */ void detectAndDisplay( Mat frame ) { vector<Rect> bodys; Mat frame_gray; cvtColor( frame, frame_gray, CV_BGR2GRAY ); equalizeHist( frame_gray, frame_gray ); //-- detect body */ body_cascade.detectMultiScale(frame_gray, bodys, 1.1, 2, 18|9, Size(3,7)); for( int j = 0; j < bodys.size(); j++ ) { Point center( bodys[j].x + bodys[j].width*0.5, bodys[j].y+ + bodys[j].height*0.5 ); ellipse( frame, center, Size( bodys[j].width*0.5, bodys[j].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 ); } imshow( window_name, frame ); }rokasmaThu, 03 Oct 2013 08:44:28 -0500 to remove detected human after DetectMultiScale? guys, now I'm workin on my False Human Detection projects. Can you tell me how to remove detected human after DetectMultiScale? So I can skip False Human Detection for the next frame detection. For Example: std::vector<cv::Rect> rects; CascadeClassifier.detectMultiScale(frame, rects); if(rects.size() > 0){ for(unsigned int r = 0; r < rects.size(); r++){ //DELETE DETECTED HUMAN (RECT) HERE! } } I'll appreciate any help here, thanks. :) ShabanTue, 12 Nov 2013 10:09:03 -0600 detection with HOG. How to improve it? Hello, I have a code for human detection, but it works not as good as I want. I read some articles that is possible to train this detector. I was searching for hour to find some good tutorials for training. Maybe you can help me. #include <iostream> #include <opencv2/opencv.hpp> using namespace std; using namespace cv; int main (int argc, const char * argv[]) { VideoCapture cap(CV_CAP_ANY); cap.set(CV_CAP_PROP_FRAME_WIDTH, 320); cap.set(CV_CAP_PROP_FRAME_HEIGHT, 240); if (!cap.isOpened()) return -1; Mat img; HOGDescriptor hog; hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); namedWindow("video capture", CV_WINDOW_AUTOSIZE); while (true) { cap >> img; if (! continue; vector<Rect> found, found_filtered; hog.detectMultiScale(img, found, 0, Size(8,8), Size(32,32), 1.05, 2); size_t i, j; for (i=0; i<found.size(); i++) { Rect r = found[i]; for (j=0; j<found.size(); j++) if (j!=i && (r & found[j])==r) break; if (j==found.size()) found_filtered.push_back(r); } for (i=0; i<found_filtered.size(); i++) { Rect r = found_filtered[i]; r.x += cvRound(r.width*0.1); r.width = cvRound(r.width*0.8); r.y += cvRound(r.height*0.06); r.height = cvRound(r.height*0.9); rectangle(img,,, cv::Scalar(0,255,0), 2); } imshow("video capture", img); if (waitKey(20) >= 0) break; } return 0; }rokasmaMon, 14 Oct 2013 07:38:21 -0500 there an OpenCV algorithm for human activity recognition? was wondering, due to my weak knowledge of OpenCV, is there some algorithm that does human activity recognition? I would like to write an application that uses algorithm for detection of human activities, like waving or swimming. I am using EmguCV, a .NET wrapper for OpenCV. Than you for your time. Gandalf_The_WhiteSat, 28 Sep 2013 11:05:15 -0500 background removal, keeping human form effects used in movies use blue-screen as the background, for easy background removal, leaving the human actors playing in a white construct, whose background could then be replaced with a surreal one. Could similar effects be created, on a continuous basis, using OpenCV ? Only challenge added to the mix is that while the background is relatively static, it is not a uniform blue-screen, rather the lighting conditions may vary from time-to-time and camera artefacts or very slight background variation (s.a. due to a window curtain flying gently due to a draft).jayachar88Fri, 19 Oct 2012 14:52:21 -0500 detector using HAAR cascades has too many false positives it is confident about, i am trying to train a HAAR-cascade to detect people. For this i generated positive samples from an recorded video by foreground-background-subtraction. I used pictures of the empty room with different arrangements and different lighting as negative samples. The trained cascade seems to detect a person with an acceptable rate. But the cascade also has a lot of false positives in regions that were not rearranged in the different negative samples. For example there is a table that could not be moved. The cascade is constantly marking the corner of the table although that table is in the negative samples and even is in EVERY negative sample. I tried different approaches to lower the false-alarm-rate but i was not very successfull. I tried to increase the number of stages to 35-40. At first that seemed to help but when i increased the number of samples using different people to get more variance the false positives reappeared. My guess is that the surrounding background in the positive samples is the cause for the false positives since the samples are from that room as well and for example parts of that table are in some samples. In another attempt i tried to decrease the size of the region i cut from the frame to get less background in my positive samples. But if i am right and the background in the samples is the reason then that lesser background might still be too much. Since from the foreground-background-subtraction i have the backgroundpixels i thought about replacing them with white noise in the positive samples. Could that help or would it be harmful? Does anybody have an alternativ solution how i can lower the false-positive-rate? I would be thankful for any assistance. GerritgerritTue, 24 Jul 2012 04:12:35 -0500