Ask Your Question

john_1282's profile - activity

2020-12-17 03:44:52 -0500 received badge  Popular Question (source)
2020-02-19 15:19:58 -0500 received badge  Popular Question (source)
2015-03-30 22:36:25 -0500 commented question Is it possible to check status of loading a big size file?

Thank boaz001. I am developing a MFC application using opencv. It must load a huge size file. Do you have any idea to check that the application is finished loading or not. Your solution is not have any flag to determine it

2015-03-30 10:44:40 -0500 commented question Bad input roi in function cvInitImageHeader

Because i used try catch to find it. Please run and see the problem.

2015-03-30 09:37:51 -0500 asked a question Is it possible to check status of loading a big size file?

Hello all, I am using the load function in opencv to load a big size file (about 64MB). It works well without error. However, when the application is loading the file, I cannot use any other task. Do we have any way to check that the file is loading? I want to show in the console that "File is loading". If it is finished, I want to show "Done". Could you suggest to me one way to do it? Thanks in advance. This is my code

cv::Ptr<cv::FaceRecognizer>  model;   
model = cv::createFisherFaceRecognizer();
2015-03-30 02:37:31 -0500 asked a question Bad input roi in function cvInitImageHeader

I am using MFC to write GUI that allows to display video from webcam using opencv 2.4.10. However, I have a error that recorded in .I using thread to show video. I used a thread to open and detect face. However, I have error is

"C:\\builds\\2_4_PackSlave-win32-vc11-shared\\opencv\\modules\\core\\src\\array.cpp:2918: error: (-25) Bad input roi in function cvInitImageHeader\n"

The problem is in code

 cv::VideoCapture cap;
 cap >> frame;

Can you help me resolve it? For full code. You can download at here.

2015-03-27 05:38:35 -0500 asked a question GUI cannot move when display video in MFC picture control

I am developing a GUI using MFC that allows to display video using opencv. The GUI allows to automatically resize the control in GUI. It works for video displaying. However, I have problem when video is opening. When video is openning, I cannot click any control or minimize button in that GUI. I also cannot click or move that GUI in the sceen. If I want to close the GUI, I must Shift+ F5 in visual studio. What is happen with my code. That problem is shown in youtube I would like to show my code as following. Thanks

void CDialogResizeDlg::OnBnClickedButton1()
    // TODO: Add your control notification handler code here
        cv::VideoCapture cap(0);
    //VideoCapture cap("C:/Users/lsf-admin/Pictures/Camera Roll/video000.mp4");
    cv::vector<cv::Rect> faces;
    cv::Mat frame;
    cv::Mat graySacleFrame;
    cv::Mat original;
    if (!cap.isOpened())

        return exit(1);

    while (true)
        cap >> frame;
        if (!frame.empty()){

        //clone from original frame
        original = frame.clone();
        CDC* vDC;
        vDC = GetDlgItem(IDC_VIDEO)->GetDC();
        CRect rect;
        IplImage* image2=cvCloneImage(&(IplImage)original);
        DisplayIplImageToPictureBox(image2, vDC, rect); //img is IplImage* variable.
        if (cv::waitKey(30) >= 0) break;

You can download my source code at here (visual 2012+ opencv 2.4.10) enter image description here

2015-03-26 09:43:42 -0500 commented answer Replace background in video by opencv

Thank Kbami and StevenPuttemans. For background changing, we can using MOG and GOG model, right? I found some tutorial of that problem at, Right?

2015-03-26 00:15:00 -0500 asked a question Replace background in video by opencv

I am looking for method and implementation to replace background in video. My goal looks like Youtube video. The author said that he used threshold value to extract background and replace them. However, I don't believed that threshold can acheived very nice result. Could you suggest to me any method that available in opencv for real time replacing background in opencv. Thank you in advance

2015-03-25 01:01:21 -0500 answered a question Face detection and comparision

The face detection looks well. However, If you want to compare (recognition), you must training the face first. You can use some database that is available such as AT. Let read that tutorial

2015-03-25 00:57:26 -0500 commented answer Real time head segmentation using opencv

Could you share your source code to my email? It is very useful for my saving time. I want to compare that method and grabcut about both accuracy and computational time. Thank you so much. My email is [email protected]

2015-03-24 08:06:45 -0500 answered a question Gender detection

It depends on your problem. What is your expected accuracy? What is your time requirement? They have trade off between time and accuracy. High accuracy increases computational time. In my experiment, I choose 100 images. In which, 50 images for male and 50 images for female. Good luck

2015-03-24 05:53:45 -0500 received badge  Student (source)
2015-03-24 03:56:06 -0500 commented question how to improve the accuracy when detecting mood and age?

@SJ: Which kind of database is used for gender detection? Currently, I used AT database, but it is very bad result. Hence, I changed to other database.

2015-03-24 03:52:13 -0500 commented question Gender-Age recognition from webcam doesn't work

I have same problem. Which kind of database is used? I am using AT data base. It is not good. So, I change to other database of a software

2015-03-24 00:12:26 -0500 received badge  Enthusiast
2015-03-24 00:12:25 -0500 received badge  Enthusiast
2015-03-23 22:23:43 -0500 commented answer Real time head segmentation using opencv

Thank fedor. Do you try to use Dlib method? It looks like fast algorithm.

2015-03-23 12:46:02 -0500 asked a question Real time head segmentation using opencv

I am using opencv 2.410 to implement a project. My project allows to segment head from video sequence which get from camera. First, I detect the head region and then apply segmentation method for that ROI region. For high accurate segmentation, I have chosen Grabcut method. However, it is very slow. I only achieved about 2 frames/second (Although I used downsampling method). I have two questions:

1. Have any faster method than Grabcut which have similar accuracy? On other hands, Do we have any way to segment head region.

2. Could you see my code and give me some optimal way to make it faster?

Thank you in advance

    #include <iostream>
    #include <string>
    #include <time.h>
    //include opencv core
    #include "opencv2\core\core.hpp"
    #include "opencv2\contrib\contrib.hpp"
    #include "opencv2\highgui\highgui.hpp"
    #include "opencv2\objdetect\objdetect.hpp"
    #include "opencv2\opencv.hpp"

    //file handling
    #include <fstream>
    #include <sstream>

    using namespace std;
    using namespace cv;

    int VideoDisplay();
    Mat GrabCut(Mat image);

    const unsigned int BORDER = 5;
    const unsigned int BORDER2 = BORDER + BORDER;

    int main()
        int value=VideoDisplay();
        return 0;
    Mat GrabCut(Mat image)
        clock_t tStart_all = clock();
        cv::Mat result; // segmentation result (4 possible values)
        cv::Mat bgModel,fgModel; // the models (internally used)
        // downsample the image
        cv::Mat downsampled;
        cv::pyrDown(image, downsampled, cv::Size(image.cols/2, image.rows/2));
        cv::Rect rectangle(BORDER,BORDER,downsampled.cols-BORDER2,downsampled.rows-BORDER2);

        clock_t tStart = clock();
        // GrabCut segmentation
        cv::grabCut(downsampled,    // input image
            result,   // segmentation result
            rectangle,// rectangle containing foreground
            bgModel,fgModel, // models
            1,        // number of iterations
            cv::GC_INIT_WITH_RECT); // use rectangle
        printf("Time taken by GrabCut with downsampled image: %f s\n", (clock() - tStart)/(double)CLOCKS_PER_SEC);

        // Get the pixels marked as likely foreground
        // upsample the resulting mask
        cv::Mat resultUp;
        cv::pyrUp(result, resultUp, cv::Size(result.cols*2, result.rows*2));
        // Generate output image
        cv::Mat foreground(image.size(),CV_8UC3,cv::Scalar(255,255,255));
        image.copyTo(foreground,resultUp); // bg pixels not copied
        return foreground;

    int  VideoDisplay(){

        cout << "start recognizing..." << endl;
        string classifier = "C:/opencv/sources/data/haarcascades/haarcascade_frontalface_default.xml";

        CascadeClassifier face_cascade;
        string window = "Capture - face detection";

        if (!face_cascade.load(classifier)){
            cout << " Error loading file" << endl;
            return -1;
        VideoCapture cap(0);
        //VideoCapture cap("C:/Users/lsf-admin/Pictures/Camera Roll/video000.mp4");

        if (!cap.isOpened())
            cout << "exit" << endl;
            return -1;

        //double fps = cap.get(CV_CAP_PROP_FPS);
        //cout << " Frames per seconds " << fps << endl;
        namedWindow(window, 1);
        long count = 0;
        int fps=0;
        //Start and end times
        time_t start,end;
        //Start the clock
        int counter=0;

        while (true)
            vector<Rect> faces;
            Mat frame;
            Mat graySacleFrame;
            Mat original;

            cap >> frame;

            double sec=difftime(end,start);

            if (!frame.empty()){

                //clone from original frame
                original = frame.clone();

                //convert image to gray scale and equalize
                cvtColor(original, graySacleFrame, CV_BGR2GRAY);
                //equalizeHist(graySacleFrame, graySacleFrame);

                //detect face in gray image
                face_cascade.detectMultiScale(graySacleFrame, faces, 1.1, 3, 0, cv::Size(90, 90));

                //number of faces detected
                //cout << faces.size() << " faces ...
2015-03-20 07:53:33 -0500 received badge  Editor (source)
2015-03-20 07:53:16 -0500 commented question Age estimation in OpenCV source code

@StevenPuttemans: The age of people in video. Sorry about my mistaken.

2015-03-20 05:16:11 -0500 asked a question Age estimation in OpenCV source code

Dear all, I am working in project that need to estimate the age of people in video input (webcam..) . Could you suggest to me some available source code openCV or approach to do it? Thank you so much

2015-03-20 05:09:19 -0500 received badge  Supporter (source)
2015-03-17 01:20:48 -0500 asked a question Fast and accurate for face segmentation in video using openCV

Hello all, I am looking for method that provides fast and accurate segmentation result for face in video using openCV. That method is avaialble in openCV. Could you suggest me some method for that task? Thank you in advance