Ask Your Question

Rah1's profile - activity

2019-03-03 20:30:54 -0600 received badge  Notable Question (source)
2018-07-16 08:17:49 -0600 received badge  Popular Question (source)
2016-06-01 13:26:13 -0600 commented question Saving Image in new folder created during runtime.

I tried this and it worked, however, my program got terminated instantly after this line

imwrite(("D:\Sample\" + foldername+"\A.jpeg").c_str(), frame);

2016-06-01 13:10:09 -0600 commented question Saving Image in new folder created during runtime.

all I wanted is to store the image in that newly created folder I tried ( \ \ ) but I am still facing error.

2016-06-01 13:04:57 -0600 received badge  Editor (source)
2016-06-01 13:01:29 -0600 asked a question Saving Image in new folder created during runtime.

I am creating a new folder with user defined name to it and I want to store image in that folder I tried this

string foldername;
Mat frame = imread("D:\\Sample\\ag.jpg", 1);
cout << "Enter Name of folder:";
getline(cin, foldername);
CreateDirectory(("D:\\Sample\\" + foldername).c_str(), NULL);
imwrite(("D:\\Sample\\" + foldername).c_str() + "A.jpeg", frame);

but the code is not working what,changes do I need to do in order to save the image in that folder name?

thankyou!

2016-05-14 00:00:04 -0600 received badge  Enthusiast
2016-05-13 15:49:56 -0600 commented answer Classification of Image

berak a little more help plz.... what things should be added to the same code to run on GPU? thanks a lot

2016-04-25 12:33:00 -0600 commented question opencv with windows form application (Visual Studio 13 GUI) c++
2016-04-25 10:49:19 -0600 asked a question opencv with windows form application (Visual Studio 13 GUI) c++

how can I write the following code in windows form application in Visual studio, not QT? I want to make use of GUI and make an interactive application that executes the function on click. I searched few links but didn't get what exactly they were trying to say.I tried adding code in header files but it is giving me an error.can someone help me and tell me steps to do GUI? here is the code.

#include "opencv2/opencv.hpp"
#include <iostream>

using namespace cv;
using namespace std;

//
// if you squint hard, you'll see the close similarity to opencv's face recognition code ;)
//
void lbp_hist(const Mat &I, Mat &histogram)
{
Mat_<uchar> img(I);
Mat_<float> hist(1, 256, 0.0f);
const int m=1;
for (int r=m; r<img.rows-m; r++)
{
    for (int c=m; c<img.cols-m; c++)
    {
        uchar v = 0;
        uchar cen = img(r,c);
        v |= (img(r-1,c  ) > cen) << 0;
        v |= (img(r-1,c+1) > cen) << 1;
        v |= (img(r  ,c+1) > cen) << 2;
        v |= (img(r+1,c+1) > cen) << 3;
        v |= (img(r+1,c  ) > cen) << 4;
        v |= (img(r+1,c-1) > cen) << 5;
        v |= (img(r  ,c-1) > cen) << 6;
        v |= (img(r-1,c-1) > cen) << 7;
        hist(v) ++;
    }
}
histogram = hist;
}

struct Classifier
{
    vector<Mat> histograms;
vector<int> labels;

Classifier( vector<Mat> &histograms, vector<int> &labels)
    : histograms(histograms)
    , labels(labels)
{} // nothing else to do

// nearest neighbour distance:
int predict(const Mat &histogram)
{
    double minDist=DBL_MAX;
    int minLabel = -1;
    for (size_t i=0; i<histograms.size(); i++)
    {
        // i tried a few, and CHISQR_ALT seemed best.
        double d = compareHist(histogram, histograms[i], HISTCMP_CHISQR_ALT);
        if (d < minDist)
        {
            minDist = d;
            minLabel = labels[i];
        }
    }
    return minLabel;
}
};

int main() 
{
    Mat ref = imread("agref.jpg",1);
     Mat a1 = imread("ag1.jpg",1);
Mat a2 = imread("ag2.jpg",1);
// make histograms
Mat h1,h2,h3;
lbp_hist(ref,h1);
lbp_hist(a1,h2);
lbp_hist(a2,h3);
// since we only got a few images(you need **lots* more!!)
// augment our train data by simply flipping the existing images:
Mat f1;  flip(ref,f1,0); // x-axis
Mat f2;  flip(a1,f2,0);
Mat f3;  flip(a2,f3,0);
Mat h4,h5,h6;
lbp_hist(f1,h4);
lbp_hist(f2,h5);
lbp_hist(f3,h6);

// setup data for classifying:
// (a histogram, and a label for each img)
vector<Mat> hists;
vector<int> labels; // 1==agglutinated, 0==not.
// ref
hists.push_back(h1); labels.push_back(0);
hists.push_back(h4); labels.push_back(0);
// agglutinated:
hists.push_back(h2); labels.push_back(1);
hists.push_back(h3); labels.push_back(1);
hists.push_back(h5); labels.push_back(1);
hists.push_back(h6); labels.push_back(1);

// "train" the classifier:
Classifier cls(hists, labels);

// flip images for testing, so they again look a bit different:
// (again, this is only for the demo)
Mat f7;  flip(ref,f7,1); // y-axis
Mat f8;  flip(a1,f8,1);
Mat f9;  flip(a2,f9,1);
Mat h7,h8,h9;
lbp_hist(f7,h7);
lbp_hist(f8,h8);
lbp_hist(f9,h9);

int p1 = cls.predict(h7); // ref
int p2 = cls.predict(h8); // agg.
int p3 = cls ...
(more)
2016-02-04 13:39:02 -0600 commented answer Classification of Image

okay thanks a lot berak :)

2016-02-04 13:02:12 -0600 received badge  Supporter (source)
2016-02-04 12:49:39 -0600 received badge  Scholar (source)
2016-02-04 12:49:28 -0600 commented answer Classification of Image

Thanks, #Berak That works just the way I wanted :) but can u help me a bit more? how can I train images and what do you mean by train images I mean how can I do it? do I need to pass more images as reference images?

2016-01-31 05:18:17 -0600 commented question Classification of Image

yup, I am looking to determine blood group.I am looking for whether the image is agglutinated or not you can see that reference image and test2 image are agglutinated while test1 image is not I want to see whether the image is agglutinated or not. if there is a better alternative than classifier that will also work I hope you got what I am looking for in an image. and thanks berak :)

2016-01-31 00:14:23 -0600 asked a question Classification of Image

1st of all I am very new to OpenCV as well as computer programming so sorry for asking a very basic and easy question but, I was not able to figure out how to do this.I want to classify blood samples images and want to determine blood group of a person. In order to do it, I have 1 reference image and test image and I want to check whether the sample image is similar to that of a reference image. if the image is same it should give me value "1" or"True" otherwise, it should give me " 0" or "False". how can I do that I am doing it in c++ and visual studio? I tried searching and found it can be done using LBP but the code was in Python and I don't know Python at all so was not able to figure it out.!

Reference image:

.image description

with

test1.image description

test2.image description

2016-01-30 14:42:59 -0600 received badge  Organizer (source)