Ask Your Question

babajj's profile - activity

2019-07-31 02:20:11 -0600 received badge  Popular Question (source)
2019-02-21 13:27:30 -0600 commented question How to (imwrite) multiple images from a live Camera

It is definitely a question. Please re-open.

2019-02-21 12:46:51 -0600 edited question How to (imwrite) multiple images from a live Camera

How to (imwrite) multiple images from a live camer Hello everyone, I successfully use this code to capture and imwrite

2019-02-21 12:41:46 -0600 asked a question How to (imwrite) multiple images from a live Camera

How to (imwrite) multiple images from a live camer Hello everyone, I successfully use this code to capture and imwrite

2016-09-19 01:17:14 -0600 received badge  Enthusiast
2016-09-18 20:08:14 -0600 asked a question Help: Face Recognition using LBP confused with unknown Faces

Hello everyone, I try to use this face recognition code below which I found on one of the Opencv documentation, but I have a problem when a new person face who is not in the recognition database is compared, the program confused saying this face is Mr.X or Mr.y or Mr.z who are already in the database. It works fine if face of the person to be compared is already in the face recognition database.

Please people, your help will kindly be appreciated.

#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"

#include <iostream>
#include <fstream>
#include <sstream>

using namespace cv;
using namespace std;

static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
    std::ifstream file(filename.c_str(), ifstream::in);
    if (!file) {
        string error_message = "No valid input file was given, please check the given filename.";
        CV_Error(CV_StsBadArg, error_message);
    string line, path, classlabel;
    while (getline(file, line)) {
        stringstream liness(line);
        getline(liness, path, separator);
        getline(liness, classlabel);
        if(!path.empty() && !classlabel.empty()) {
            images.push_back(imread(path, 0));

int main(int argc, const char *argv[]) {
    // Check for valid command line arguments, print usage
    // if no arguments were given.
    if (argc != 2) {
        cout << "usage: " << argv[0] << " <csv.ext>" << endl;
    // Get the path to your CSV.
    string fn_csv = string(argv[1]);
    // These vectors hold the images and corresponding labels.
    vector<Mat> images;
    vector<int> labels;
    // Read in the data. This can fail if no valid
    // input filename is given.
    try {
        read_csv(fn_csv, images, labels);
    } catch (cv::Exception& e) {
        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
        // nothing more we can do
    // Quit if there are not enough images for this demo.
    if(images.size() <= 1) {
        string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
        CV_Error(CV_StsError, error_message);
    // Get the height from the first image. We'll need this
    // later in code to reshape the images to their original
    // size:
    int height = images[0].rows;
    // The following lines simply get the last images from
    // your dataset and remove it from the vector. This is
    // done, so that the training data (which we learn the
    // cv::FaceRecognizer on) and the test data we test
    // the model with, do not overlap.
    Mat testSample = images[images.size() - 1];
    int testLabel = labels[labels.size() - 1];
    // The following lines create an LBPH model for
    // face recognition and train it with the images and
    // labels read from the given CSV file.
    // The LBPHFaceRecognizer uses Extended Local Binary Patterns
    // (it's probably configurable with other operators at a later
    // point), and has the following default values
    //      radius = 1
    //      neighbors = 8
    //      grid_x = 8
    //      grid_y = 8
    // So if you want a LBPH FaceRecognizer using a radius of
    // 2 and 16 neighbors, call the factory method with:
    //      cv::createLBPHFaceRecognizer(2, 16);
    // And if you want a threshold (e.g. 123.0) call it with its default values ...
2016-09-06 08:36:43 -0600 asked a question Bring an Object that appear far in an Image closer to your view !

Hello everyone,

I am new in Image processing, so I would like to know whether it is possible to bring an object that appear far in an image closer to the view of the user?

Please advice if there is any techniques in opencv or matlab that can address this issue.

Thanking you.

2016-08-31 20:39:01 -0600 commented question Extract the Date and Time an Image was taken using OpenCV!!!

@break. Thank you so much. I used the OS function you suggested and it works fine for me. @Eduardo You call it a Joke? Really ? I think it's better to share something if you have any.

2016-08-31 08:02:43 -0600 commented question Extract the Date and Time an Image was taken using OpenCV!!!

@berak. Thank you for the comment, but anything related to images or image processing is related to Opencv.

2016-08-31 07:00:38 -0600 commented question Extract the Date and Time an Image was taken using OpenCV!!!

@sturkmen, thanks for the comment, but that won't work well if I want to use it later to save date and time in my database.

2016-08-31 06:59:01 -0600 received badge  Editor (source)
2016-08-31 06:25:25 -0600 asked a question Extract the Date and Time an Image was taken using OpenCV!!!

Hello everyone, I wrote a program that capture an Image from a Webcam and save the image in a folder. Now , I want to extract the date and the time that Image was taken using Opencv. I will use this extracted date and time later in another Database Program.

Thanking you,

Best Regards,

2016-07-28 22:02:07 -0600 asked a question Accesing MS Access Face Database using OpenCV C++

Hello everyone,

I am definitely new in OpenCV. I am current working on an automated attendance management system using face recognition. I completed the face detection part, now working on how to implement the recognition part.

I already developed my Face Database (which will be compared with the detected faces), so are there any good tutorials, demo code or links that could guide me to write the c++ code to read and write images from and to the MS access database?

Thanking you in advance,

2016-07-25 23:26:42 -0600 answered a question How can I do this? PSEye Capture Video

You can use this code: Please know that we are using a single camera, but if you want to use four cameras please uncomment other additional 3 cameras in order to achive your goal ::

// USBCameraVideoCapture.cpp : 定义控制台应用程序的入口点。 //

include "stdafx.h"

include <opencv cv.h="">

include <opencv2 opencv.hpp="">

include <opencv2 core="" core.hpp="">

include <opencv2 imgproc="" imgproc.hpp="">

include <opencv2 highgui="" highgui.hpp="">

using namespace cv; using namespace std;

int _tmain() { CvCapture capture0=cvCreateCameraCapture(0);//建立opencv图像捕获对象 //CvCapture *capture1=cvCreateCameraCapture(1); /CvCapture capture2=cvCreateCameraCapture(2); CvCapture *capture3=cvCreateCameraCapture(3); CvCapture *capture4=cvCreateCameraCapture(4);/ capture0=cvCaptureFromCAM(0);//cvCaptureFromCAM函数初始化第一个摄像头的采集(索引为0)。如果索引传入的为1,那么它初始化的是第二个摄像头 //capture1=cvCaptureFromCAM(1); /capture2=cvCaptureFromCAM(2); capture3=cvCaptureFromCAM(3); capture4=cvCaptureFromCAM(4);/ IplImage frame0=NULL; //IplImage *frame1=NULL;
IplImage frame2=NULL; IplImage *frame3=NULL; IplImage *frame4=NULL;/

double fps=20;
CvSize size0=cvSize((int)(capture0,CV_CAP_PROP_FRAME_WIDTH),(int)(capture0,CV_CAP_PROP_FRAME_HEIGHT));
CvVideoWriter *writer0=cvCreateVideoWriter("e:/test0.avi",CV_FOURCC('X','V','I','D'),fps,size0);
CvSize size1=cvSize((int)(capture1,CV_CAP_PROP_FRAME_WIDTH),(int)(capture1,CV_CAP_PROP_FRAME_HEIGHT));
CvVideoWriter *writer1=cvCreateVideoWriter("e:/test1.avi",CV_FOURCC('X','V','I','D'),fps,size1);*/

/*CvSize size2=cvSize((int)(capture2,CV_CAP_PROP_FRAME_WIDTH),(int)(capture2,CV_CAP_PROP_FRAME_HEIGHT));
CvVideoWriter *writer2=cvCreateVideoWriter("e:/test2.avi",CV_FOURCC('X','V','I','D'),fps,size2);

CvSize size3=cvSize((int)(capture3,CV_CAP_PROP_FRAME_WIDTH),(int)(capture3,CV_CAP_PROP_FRAME_HEIGHT));
CvVideoWriter *writer3=cvCreateVideoWriter("e:/test3.avi",CV_FOURCC('X','V','I','D'),fps,size3);

CvSize size4=cvSize((int)(capture4,CV_CAP_PROP_FRAME_WIDTH),(int)(capture4,CV_CAP_PROP_FRAME_HEIGHT));
CvVideoWriter *writer4=cvCreateVideoWriter("e:/test4.avi",CV_FOURCC('X','V','I','D'),fps,size4);*/



// cvDestroyWindow("camera1"); //cvReleaseImage(&frame2); ////cvReleaseCapture(&capture2); //cvDestroyWindow("camera2"); //cvReleaseImage(&frame3); ////cvReleaseCapture(&capture3); //cvDestroyWindow("camera3");
// cvReleaseImage(&frame4); ////cvReleaseCapture(&capture4); //cvDestroyWindow("camera4");
return 0;


2016-07-25 23:26:41 -0600 asked a question error: identifier cv::Mat is undefined !!!

Hello Everyone ,

I am very new in OpenCv, so I am writing a code that will detect a face from webcam, but whenever i try to follow the sample code in the book i am using. The cv::Mat will not be recognize, but IplImage * img is always working fine.

What could be the possible problem ?

Thank you all in advance !