Ask Your Question

Mehdi.Am's profile - activity

2020-03-27 21:24:48 -0600 received badge  Popular Question (source)
2018-10-08 05:04:35 -0600 received badge  Notable Question (source)
2018-06-22 04:25:38 -0600 received badge  Notable Question (source)
2018-05-28 10:44:20 -0600 received badge  Popular Question (source)
2018-01-21 00:12:20 -0600 asked a question Looking for survey articles about plate recognition (ANPR)

Looking for survey articles about plate recognition (ANPR) Dear guys I'm looking for ANPR Survey articles for my final

2017-09-04 15:23:03 -0600 received badge  Student (source)
2017-09-04 15:18:05 -0600 received badge  Popular Question (source)
2017-07-06 20:02:44 -0600 received badge  Popular Question (source)
2017-07-04 20:25:36 -0600 received badge  Popular Question (source)
2017-04-19 01:19:39 -0600 asked a question How Can I display HSV output in a picture box?

Dear friends

Recently, I tried to display an output which is converted to HSV, into a picture box.
unfortunately nothing is shown in picturebox but when I use none-HSV image (BGR) it will be displayed!

here is part of my code:

IplImage returnOutputImage()
{
    Mat dst;

    //Brightness Contrast Calibration
    double dContrast = trackBar2->Value / 50.0;
    int iBrightness = trackBar3->Value - 50;

    //HSV Calibration
     int iLowH = 170; //trackBarHueMin->Value; 
     int iHighH = 179;//trackBarHueMax->Value;

     int iLowS = 150; //trackBarSatMin->Value; 
     int iHighS = 255;//trackBarSatMax->Value;

     int iLowV = 60; //trackBarValMin->Value;
     int iHighV =  255;//trackBarValMax->Value;


    cv::Mat s = cv::cvarrToMat(ip_frame);
    s.convertTo(dst, -1, dContrast,iBrightness); 

    Mat imgHSV,imgThresholded,dstnEW;
    cvtColor(dst, imgHSV, CV_BGR2HSV);
    inRange(imgHSV, Scalar(iLowH, iLowS, iLowV), Scalar(iHighH, iHighS, iHighV), imgThresholded); //Threshold the image

    //cvtColor(imgThresholded, dstnEW, CV_HSV2RGB_FULL);

    IplImage dstNew = imgThresholded;
    return dstNew;
}

finally,here I wanna show this image:

pictureBox2->Image  = gcnew System::Drawing::Bitmap(ip_frame->width,ip_frame->height,ip_frame->widthStep,System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr) returnOutputImage().imageData);
2016-12-16 01:33:37 -0600 asked a question How can I connect to an ip camera using java in android eclipse?

Dear users

I'm trying to connect to an ip camera using opencv android 2.4 in eclipse. I read some resources but I couldn't find any clear code to do it.

can someone help me?

2015-12-10 11:13:25 -0600 asked a question how can I read digits from white background?

Hi Buddies Can you help to recognize digits from a white background? as an example this palate:

image description

In fact if you tell me how I can read digits.

2015-12-10 08:14:05 -0600 commented question I can't use findcounters because of facing Unhandled exception

@berak tnx alot,It's solved,I put it in release mode :)

2015-12-10 08:11:37 -0600 commented question I can't use findcounters because of facing Unhandled exception

@LorenaGdL ok sure :) I did it

2015-12-10 05:21:01 -0600 asked a question I can't use findcounters because of facing Unhandled exception

Hi guys

Can you help me clearly that how I can fix this problem? What is the main reason of this error. when I run my code, this error appears:

image description

my code is here: (I use Opencv 2.4 and VS 2012)

// ConsoleApplication4_test_findcounter.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "opencv2\core\core.hpp"
#include "opencv2\highgui\highgui.hpp"
#include "opencv2\imgproc\imgproc.hpp"
#include "iostream"
using namespace cv;
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{

    Mat image;
    image = imread("shape.JPG", 1);  
    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );  
    imshow( "Display window", image );
    Mat gray;
    cvtColor(image, gray, CV_BGR2GRAY);
    Canny(gray, gray, 100, 200, 3);
    /// Find contours   
    vector<vector<Point> > contours;
    vector<Vec4i> hierarchy;
    RNG rng(12345);

    findContours( gray, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

    /// Draw contours
    Mat drawing = Mat::zeros( gray.size(), CV_8UC3 );
    for( int i = 0; i< contours.size(); i++ )
    {
        Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
        drawContours( drawing, contours, i, color, 2, 8, hierarchy, 0, Point() );
    }     

    imshow( "Result window", drawing );
    waitKey(0);                                         

    return 0;
}
2015-12-10 01:39:21 -0600 asked a question facing an error when using "findContours"

Dear buddies

I want to find counters of one captured frame from a live camera (my goal is to detect plate number). Unfortunately, when I use this code:

cv::findContours(im2, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);

after running my program, this window appears:

image description

here is my code: (after clicking, this block starts)

void rgb2cmyk(cv::Mat& src, std::vector<cv::Mat>& cmyk)
{
    CV_Assert(src.type() == CV_8UC3);

    cmyk.clear();
    for (int i = 0; i < 4; ++i)
        cmyk.push_back(cv::Mat(src.size(), CV_32F));

    for (int i = 0; i < src.rows; ++i)
    {
        for (int j = 0; j < src.cols; ++j)
        {
            cv::Vec3b p = src.at<cv::Vec3b>(i,j);

            float r = p[2] / 255.;
            float g = p[1] / 255.;
            float b = p[0] / 255.;
            float k = (1 - std::max(std::max(r,g),b));

            cmyk[0].at<float>(i,j) = (1 - r - k) / (1 - k); 
            cmyk[1].at<float>(i,j) = (1 - g - k) / (1 - k);
            cmyk[2].at<float>(i,j) = (1 - b - k) / (1 - k);
            cmyk[3].at<float>(i,j) = k;
        }
    }
}
...

void ... btnclick() {

  cv::Mat im0(frame);

    std::vector<cv::Mat> cmyk;
    rgb2cmyk(im0, cmyk);

    cv::Mat im1;
    im1 = cmyk[3].mul(1 - cmyk[1]) > 0.25;

    cv::Mat im2,threshold;
    im1.convertTo(im2, CV_LOAD_IMAGE_GRAYSCALE);

    std::vector<std::vector<cv::Point> > contours;

    cv::findContours(im2, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
}
2015-10-25 16:08:46 -0600 asked a question How to get better results with OpenCV face recognition

I'm trying to use OpenCV's face recognition module to recognize 2 faces from a video. I cropped 20 face images of the first subject and 20 face images of the second subject from the video and I use these as my training set.

I've tested Fisherfaces but I'm not getting good results in this program. Sometimes the first subject is classified as the second subject and vice-verse (I mean sometimes it detects the correct lable sometimes it predict incorrectly ), sometimes false detections are classified as one of the two subjects and sometimes other people in the video are classified as one of the two subjects.

How can I improve performance?

I think increasing the face samples may not solve it completely!So what I should do here:

here is a part of my code which check the condition of labels:

if (label == 2){
                    //string text = format("Person is  = %d", label);
                    Pname = "Mehdi";
                }
                else if(label == 3)
                {
                    Pname = "Kourosh";
                }
                else{
                    Pname = "unknown";
                }
2015-10-22 08:07:06 -0600 commented question Myproject.exe has triggered a breakpoint.

@StevenPuttemans don't you think that it's devoted to array size?

2015-10-22 07:03:17 -0600 asked a question Myproject.exe has triggered a breakpoint.

Hi guys

When I compile my code I face this error:

kooh1.exe has triggered a breakpoint.

, I don't know exactly what the problem is! maybe the size of the array caused this error:

here is a part of my code:(when it detects a face this error appears)

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 detected" << endl;
            std::string frameset = std::to_string(count);
            std::string faceset = std::to_string(faces.size());

            int width = 0, height = 0;

            //region of interest
            //cv::Rect roi;

            //person name
            string Pname = "";

            for (int i = 0; i < faces.size(); i++)
            {
                //region of interest
                Rect face_i = faces[i];

                //crop the roi from grya image
                Mat face = graySacleFrame(face_i);

                //resizing the cropped image to suit to database image sizes
                Mat face_resized;
                cv::resize(face, face_resized, Size(img_width, img_height), 1.0, 1.0, INTER_CUBIC);

                //recognizing what faces detected
                int label = -1; double confidence = 0;
                model->predict(face_resized, label, confidence);

                cout << " confidencde " << confidence << endl;

                //drawing green rectagle in recognize face
                rectangle(original, face_i, CV_RGB(0, 255, 0), 1);
                string text = "Detected";
                if (label == 40){
                    //string text = format("Person is  = %d", label);
                    Pname = "gihan";
                }
                else{
                    Pname = "unknown";
                }


                int pos_x = std::max(face_i.tl().x - 10, 0);
                int pos_y = std::max(face_i.tl().y - 10, 0);

                //name the person who is in the image
                putText(original, text, Point(pos_x, pos_y), FONT_HERSHEY_COMPLEX_SMALL, 1.0, CV_RGB(0, 255, 0), 1.0);
                //cv::imwrite("E:/FDB/"+frameset+".jpg", cropImg);

            }


            putText(original, "Frames: " + frameset, Point(30, 60), CV_FONT_HERSHEY_COMPLEX_SMALL, 1.0, CV_RGB(0, 255, 0), 1.0);
            putText(original, "Person: " + Pname, Point(30, 90), CV_FONT_HERSHEY_COMPLEX_SMALL, 1.0, CV_RGB(0, 255, 0), 1.0);
            //display to the winodw
            cv::imshow(window, original);

            //cout << "model infor " << model->getDouble("threshold") << endl;

        }
        if (waitKey(10) >= 0) cout<<"hi"<<endl;
    }

}
2015-10-19 04:38:39 -0600 asked a question No symbols loaded for opencv_contrib2410.dll

I am trying just a basic face recognition program with OpenCV2.4 with the following code:

#include "stdafx.h"
#include <iostream>
#include <string>

//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;

static void dbread(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';'){
    std::ifstream file(filename.c_str(), ifstream::in);

    if (!file){
        string error = "no valid input file";
        CV_Error(CV_StsBadArg, error);
    }

    string line, path, label;
    while (getline(file, line))
    {
        stringstream liness(line);
        getline(liness, path, separator);
        getline(liness, label);
        if (!path.empty() && !label.empty()){
            images.push_back(imread(path, 0));
            labels.push_back(atoi(label.c_str()));
        }
    }
}



void fisherFaceTrainer(){
    /*in this two vector we put the images and labes for training*/
    vector<Mat> images;
    vector<int> labels;

    try{        
        string filename = "mycsv.txt";
        dbread(filename, images, labels);

        cout << "size of the images is " << images.size() << endl;
        cout << "size of the labes is " << labels.size() << endl;
        cout << "Training begins...." << endl;
    }
    catch (cv::Exception& e){
        cerr << " Error opening the file " << e.msg << endl;
        exit(1);
    }


    Ptr<FaceRecognizer> model = createFisherFaceRecognizer();

    model->train(images, labels);

    int height = images[0].rows;

    model->save("fisherface.yml");

    cout << "Training finished...." << endl;
}


int _tmain(int argc, _TCHAR* argv[])
{
    fisherFaceTrainer();
    //int value = FaceRecognition();
    return 0;
}

When I run this, I get this error(no-symbols-loaded-for-opencv_contrib2410): no-symbols-loaded-for-opencv_contrib2410

*Right click on image>>open image in new tab>>to check the bigger size

Thanks for helping

2015-10-17 01:46:42 -0600 commented answer When I use OpenCV 2.4,the image does not load!

@StevenPuttemans I did it,but it's not working yet!

2015-10-16 03:27:10 -0600 commented answer identifier "FaceRecognizer" is undefined OpenCV 3.0.0

thank you @berak but you know,instead I decided to use opencv 2.4 to not face this problem,but unfortunately imread() function doesn't work well..I mean it doesn't load the image via opencv 2.4.look at here please (this is my problem):
http://answers.opencv.org/question/73...

2015-10-16 03:24:07 -0600 commented question identifier "FaceRecognizer" is undefined OpenCV 3.0.0

thank you @berak but you know,instead I decided to use opencv 2.4 to not face this problem,but unfortunately imread() function doesn't work well..I mean it doesn't load the image via opencv 2.4.look at here please (this is my problem):
http://answers.opencv.org/question/73...

2015-10-16 02:46:55 -0600 asked a question identifier "FaceRecognizer" is undefined OpenCV 3.0.0

Hi Friends

I need to use the following code via OpenCV 3.0.0 but it's not accepted by compiler and this error appears,

In fact, when I use OpenCV 2.4 it doesn't appear and it can be detected.

I don't know which header I should include that I didn't!

here is an abstract of my code (via opencv 3.0.0):

      #include "opencv2/core.hpp"
        #include "stdafx.h"
        #include "opencv2\imgproc\imgproc.hpp"
        #include <iostream>
        #include <fstream>
        #include <opencv2\calib3d\calib3d.hpp>
        #include "opencv2\core\core.hpp"
        #include "opencv2\highgui\highgui.hpp"
        #include "opencv2\objdetect\objdetect.hpp"
        #include "opencv2\opencv.hpp"

        using namespace cv;
        using namespace std;
    main()
{
      ...
    Ptr<FaceRecognizer> model = createFisherFaceRecognizer(); //it doesn't detect FaceRecognizer

    model->train(images, labels);
      ...
}
2015-10-15 07:23:24 -0600 commented question Can't create CSV file

@berak I did

2015-10-15 07:22:50 -0600 asked a question When I use OpenCV 2.4,the image does not load!

In my prev problem, I found out that the image doesn't load in my project when I use OpenCV 2.4 so I couldn't create CSV file.

when I was using OpenCV 3.0.0 every thing was OK and I could load the image via imread

but now I'm using OpenCV 2.4 but the image doesn't load and always img.empty() command return true

here is my code but the img is null:

// faceRecognitionTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include "opencv2\contrib\contrib.hpp"
#include "opencv2\core\core.hpp"
#include "opencv2\highgui\highgui.hpp"
#include "opencv2\objdetect\objdetect.hpp"
#include "opencv2\opencv.hpp"
#include "opencv2\imgproc\imgproc.hpp"
#include "FaceRec.h"

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

using namespace std;
using namespace cv;


Mat img;

int _tmain(int argc, _TCHAR* argv[])
{
 img = imread("f.jpg",CV_LOAD_IMAGE_GRAYSCALE);
    if (img.empty())
    {
        return -1;
    }


    saveMatToCsv(img,"mycs.csv");

    //fisherFaceTrainer();
    return 0;
}
2015-10-15 07:12:37 -0600 edited question Can't create CSV file

Can someone tell me how I can create CSV file?

2015-10-15 03:30:56 -0600 commented answer Can't create CSV file

@LorenaGdL I try but my problem doesn't belong to loading image. the problem is allocated to format function which is shown here: error image I used your suggestions but I have this problem yet,I tried different solutions before posting my question :(

2015-10-15 03:10:10 -0600 commented answer Can't create CSV file

@LorenaGdL what do you mean?yes I think so. if it's wrong please correct my code. thank you dear

2015-10-15 02:46:25 -0600 commented answer Can't create CSV file

@LorenaGdL May I ask you to edit my code?

int _tmain(int argc, _TCHAR* argv[])
{
    Mat img = imread("f.jpg",CV_LOAD_IMAGE_GRAYSCALE);
    saveMatToCsv(img,"mycsv.csv");
    //fisherFaceTrainer();
    return 0;
}

//------------------

void saveMatToCsv(Mat &matrix, string filename){
    ofstream outputFile(filename);
    outputFile << format(matrix, "CSV") << endl;
    outputFile.close();
}

I use OpenCV 2.4

2015-10-15 01:11:50 -0600 commented answer Can't create CSV file

@theodore @LorenaGdL I faced this error could you plz solve it?I captured my error.please look at it: error pic

and this is my main funtion that I call it: main fun pic