Ask Your Question

fredreload's profile - activity

2020-10-08 13:34:48 -0600 received badge  Popular Question (source)
2018-11-07 15:39:15 -0600 received badge  Notable Question (source)
2017-08-10 15:47:10 -0600 received badge  Popular Question (source)
2017-04-28 13:58:29 -0600 commented question 3d data recognition

How about an algorithm?

2017-04-28 12:35:56 -0600 commented question 3d data recognition

Hmm, what software would you recommend for 3D data recognition?

2015-11-11 19:34:27 -0600 asked a question Bounding box For characters

Hi, I am currently using this program provided by OpenCV to get the bounding box for my characters. The problem is the largest bounding box rectangle surrounds the entire image so when I do CV_RETR_EXTERNAL only the largest rectangle shows. I want to know how to remove the largest bounding box so I can get a bounding box for each character. I also want the bounding box to be in order in x axis from left to right so I can analyze them. I know

for( int i = 0; i< contours.size(); i++ )
{
Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
rectangle( drawing, boundRect[i].tl(), boundRect[i].br(), color, 2, 8, 0 );
}

Is supposed to loop through all the boundRect but most of them is showing -1 in my case so I am not sure how to group them by x axis. Below is an image of my output and I want to remove the largest blue bounding box rectangle.

image description

2015-11-11 08:59:00 -0600 commented question Image search in database

The features you get can be classified. Basically you have a vector of features and you can do bag of words with it. Since I've never worked on it, someone probably has a better answer.

2015-11-10 07:56:05 -0600 commented question tesseract-ocr spacing problem

Is there a way to get the distance between the bounding box?

2015-11-10 07:06:27 -0600 commented question Image search in database

Those two are the same if I remember, bag of words for images using FLANN features.

2015-11-10 07:04:43 -0600 asked a question tesseract-ocr spacing problem

I am using tesseract-ocr portable version exe with psm 3 to run the rectangle of bitmap for my images. The problem is it has incorrect spacing for some words(e.g. "this group" becomes "thisgroup"). I tried to correct this problem by resizing the bitmap to a larger size which successfully solves this problem, but then other spacing problem appears(e.g. "apple" becomes "appl e"). The words in the example is not the same as my test file but due to company policy I cannot reveal them. I think resizing the bitmap might not be the best way to solve the spacing problem. Is there other methods I can try out? I also heard there is a way to wrap the word in white rectangle, but I have not found the method. Can someone give me a lead as to the spacing problem?

2015-10-28 02:31:14 -0600 commented question Trying to run OpenCV as a 32bit exe file

Alright it is Tesseract-OCR problem, I have it removed and now I am getting empty images. I guess I installed it in my home computer some time before and forgot. How do I get it to work without a .net wrapper?

2015-10-28 02:15:12 -0600 asked a question Trying to run OpenCV as a 32bit exe file

So here is my story. I am creating a program for OCR with tesseract. I installed OpenCV C++ on a 32 bit window and created an exe file name Project4.exe with the following dll files: opencv_videoio300.dll opencv_imgproc300.dll opencv_imgcodecs300.dll opencv_highgui300.dll opencv_core300.dll libtesseract302.dll liblept168.dll

Now I ran the exe file with these dlls in the C# platform as a asynchronous process and everything works. The user interface imshow() also shows up.

Now when I transfer these files to another computer with a 64 bit window, the program runs the standard std out message when I give too few arguments. But besides that nothing shows up for OCR or the user interface imshow() with the image I want. I am running the webform of the 64 bit window computer in my 32 bit computer and I am not sure if the user interface is supposed to show up by running the exe remotely in this method.

Lastly, when I transfer all the files into the 64bit windows computer back home, everything works again as I am using Visual Studio 2013. So my conclusion is, 64bit window is not the problem because the program runs as I provided them with the correct dlls files. I am not sure if OpenCV or Tesseract part of the program is working since I cannot get an image output and both those programs are not installed in the remote 64bit window computer. Either that or something is locked in the remote computer. This is all the information I am getting. Please help.

2015-10-04 07:31:33 -0600 commented answer Remove all background and show only words for OCR

Cool, I did an Otsu threshold and it works out nicely, also note that increasing the font also helps generate a more accurate OCR.

2015-10-02 08:25:28 -0600 asked a question Remove all background and show only words for OCR

So I am currently working on OCR with tesseract-ocr, the problem it does not recognize the words with a green background. So I need to do pre-processing by making the background completely white and leaving "only" the black words for tesseract OCR. I would like to know how to do that for the image and if there are other pre-processing techniques I can use to raise the accuracy. Thanks.

2015-05-27 02:44:01 -0600 received badge  Student (source)
2015-05-26 23:29:09 -0600 asked a question cv_32s and comparehist

I managed to produce histograms of cv_32s by following this tutorial (http://opencv-code.com/tutorials/draw...), but the problem is after getting the two histograms I would like to compare them using a compare function, but comparehist would not take a histogram of cv_32s format. If I change the format to cv_32f it would not give the right answer for Kullback Leibler(cv_kl_div) comparison. So how can I compare 2 cv_32s histograms with Kullback Leibler?

2015-05-19 23:09:02 -0600 asked a question c# process cvtcolor error

I tried to run an Opencv program using process from c#, for some reason it is giving me a cvtcolor error even though it runs correctly in c++. Can someone tell me how to fix this error?

run_cmd1(@"C:/Project5/Debug/Project5.exe", "");

private void run_cmd1(string cmd, string args)
        {
            Process process = new Process();
            process.StartInfo.FileName = cmd;
            process.StartInfo.Arguments = args; // Put your arguments here
            process.Start();
        }

image description

2015-05-14 09:01:56 -0600 commented question Image search in database

Try Bag of Features, never tried it.

2015-05-13 23:38:41 -0600 commented question Where can i find a fast opencv c++ code to compute LBP and LTP histograms?

I have 3 posts on LBP, you can check it for useful infos :P, one has a LBP.cpp by bytefish and another one has histogram comparison implemented using CHI-SQR.

2015-05-13 23:36:06 -0600 commented question Face-recognition program in Galileo IoT DevKit

You can check out the Python code for local binary pattern unless you have a specific way you want to implement the face detection. The Python code uses Numpy histogram and Skimage for texture matching. Haven't done LBP for facerec but I think they are similar.

2015-05-13 23:32:45 -0600 commented question Is Feature extraction done in FaceRecognizer

If you use feature extraction it will have problems when you try to match a face in which you do not have features for. I tried doing SURF and SIFT on texture matching and it does not turn out well. The feature you are looking for is probably local binary pattern that you can extract to match for a similar histogram. Histogram comparison should work better unless someone prove me wrong.

2015-05-13 05:51:59 -0600 commented question how to normalize local binary pattern for kullback leibler?

CHI_SQR works, thanks for the help!

2015-05-13 05:50:24 -0600 commented question how to normalize local binary pattern for kullback leibler?

And CHI_SQR works, thanks for the help berak.

2015-05-13 05:41:27 -0600 commented question how to normalize local binary pattern for kullback leibler?

Opencv cv calchist can only process CV_32FC1 or CV8UC1. If you pass CV_32SC1 it gives an error.

2015-05-13 05:27:51 -0600 commented question how to normalize local binary pattern for kullback leibler?

That's the format I'm having trouble with. After converting CV_32SC1 to CV_32FC1 for Opencv calcHist, the kullback-leibler gives a negative value. I'm thinking of just using original LBP since it stays the same as CV_8UC1. What is a good histogram analysis for the original LBP? Chi-Square? Or Histogram intersection?

2015-05-13 04:16:48 -0600 commented question how to normalize local binary pattern for kullback leibler?

The lbp code I got is too old, I need to check out some conversions. Either that or I need to stick with OLBP.

2015-05-13 03:58:48 -0600 asked a question how to normalize local binary pattern for kullback leibler?

This is my third post for local binary pattern. I've gotten the scikit-image code to work here (http://scikit-image.org/docs/dev/auto...), but I would like to transport my result to Opencv. The scikit-image code does a histogram like this, hist, _ = np.histogram(lbp, normed=True, bins=n_bins, range=(0, n_bins)) with lbp being the lbp image, and n_bins being n_bins = lbp.max() + 1 which I checked is 18.0. They also have it normalized. This is using Numpy histogram with radius 2 and neighbor 16. Now I do the same thing with Opencv cv::calcHist( &lbp, 1, channels, Mat(), lbp_hist, 1, histSize, ranges, true, false ); with lbp being the lbp image for radius 2 and neighbor 16, except I change the histsize and ranges to 256. I believe this should be the same as Numpy Histogram. The problem is when I try to normalize the Opencv histogram with the normalize function normalize(lbp_hist, lbp_hist, 0, 1, NORM_MINMAX, -1, Mat() ); from 0 to 1. And then do a compare histogram with Kullback-Leibler double base_base = compareHist( lbp_hist, lbp1_hist, CV_COMP_KL_DIV );, I still get negative values sometimes. So my question is, how do I normalize the histogram correctly in range with radius 2 and neighbor 16? Below is my code.

P.S. I found out it has something to do with the conversion from CV_32SC1 to CV_32FC1 to CV_8UC1. But still get negative values.

#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/xfeatures2d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "lbp.hpp"
#include "histogram.hpp"

using namespace cv;

int main(int argc, const char *argv[]) {

    // initial values
    int radius = 2;
    int neighbors = radius*8;

    // matrices used
    Mat test;
    Mat test1;
    Mat frame; // always references the last frame
    Mat dst; // image after preprocessing
    Mat dst1;
    Mat lbp; // lbp image
    Mat lbp1;

    Mat lbp_hist, lbp1_hist;

    int histSize[] = {256};

    float s_ranges[] = { 0, 256 };

    const float* ranges[] = { s_ranges };

    // Use the o-th and 1-st channels
    int channels[] = { 0 };

    dst = imread("B10.png", 1); //Load as grayscale
    cvtColor(dst, dst, CV_BGR2GRAY);
    lbp::ELBP(dst, lbp, 2, 16); // use the extended operator

    lbp.convertTo(lbp, CV_32FC1);
    normalize(lbp, lbp, 0, 255, NORM_MINMAX);

    imshow("lbp", lbp);
    waitKey(0);

    cv::calcHist( &lbp, 1, channels, Mat(), lbp_hist, 1, histSize, ranges, true, false );
    normalize(lbp_hist, lbp_hist, 0, 1, NORM_MINMAX, -1, Mat() );

    show_histogram("lbp_h", lbp);
    waitKey(0);

    int lbp_operator=1;

    for (int i=1; i<31; i++) {
        dst1 = imread("B" + to_string(i) +".png", 1); //Load as grayscale
        cvtColor(dst1, dst1, CV_BGR2GRAY);

        lbp::ELBP(dst1, lbp1, 2, 16); // use the original operator

        lbp1.convertTo(lbp1, CV_32FC1);

        normalize(lbp1, lbp1, 0, 255, NORM_MINMAX);

        cv::calcHist( &lbp1, 1, channels, Mat(), lbp1_hist, 1, histSize, ranges, true, false );
        normalize(lbp1_hist, lbp1_hist, 0, 1, NORM_MINMAX, -1, Mat() );

        double base_base = compareHist( lbp_hist, lbp1_hist, CV_COMP_KL_DIV );

        printf("%f is %d\n",base_base,i);
    }
    system("pause");
    return 0; // success
}
2015-05-11 22:03:13 -0600 commented answer local binary pattern with texture classification

hist.at<int>(0,y) = histograms[histIdx].at<int>(valIdx); This line keeps giving me error though.

2015-05-11 09:40:34 -0600 answered a question local binary pattern with texture classification

Here's another question. I am looking at the code for spatial_histogram one that's made up of many n*n histograms, but I cannot figure out a few parameters for the function. If someone can help me out it would be cool.

void lbp::spatial_histogram(const Mat& src, Mat& hist, int numPatterns, const Size& window, int overlap)

I have lbp image for src, and empty Mat for hist. I give 16 for numPatterns since I think it is asking for neighbors. Then I set a size for Size dsize = Size(lbp.cols/4, lbp.rows/4); for window, and 0 for overlap but I am not sure what numPatterns, window, and overlap are. What is gridx and gridy?

2015-05-11 04:21:44 -0600 commented question LBP with HSV is not working.

Right well, I am thinking of doing Gabor filter, but does it apply for color images (color + shape)? For 2D textures, not faces.

2015-05-11 04:11:55 -0600 commented question LBP with HSV is not working.

Man, there's no color and shape analysis, does it mean it's not doable?

2015-05-11 03:53:27 -0600 commented question LBP with HSV is not working.

On second thought, maybe my image is correct but I need a different histogram comparison this time.

2015-05-11 03:17:20 -0600 commented question LBP with HSV is not working.

I want to do a similar texture comparison but with color and shape, not just gray image with shape only. Well, it is calculated base on 3 different channels from k=0 to k=2. But it seems this code does not work for the color images, I might have to find another one.

2015-05-11 02:53:14 -0600 asked a question LBP with HSV is not working.

So I tried to use the bytefish code again and tried to run it for color images, HSV, RGB, but the result does not show up well. What I did is load in the image as RGB. Pass the CV_8UC3 as Vec3b. Use the ELBP to compute individual bit for R, G, and B as shown below. But the image looks bad either as HSV or RGB. RGB gets a distance result with Kullback but the image does not match. HSV gets negative value which is not supposed to happen. Does this code not work for color images?

void lbp::ELBP(const Mat& src, Mat& dst, int radius, int neighbors) {
    switch(src.type()) {
        case CV_8UC3: ELBPA_<cv::Vec3b>(src, dst, radius, neighbors); break;
    }
}

for(int i=radius; i < src.rows-radius;i++) {
            for(int j=radius;j < src.cols-radius;j++) {
                for(int k=0; k<3; k++)
                {
                float t = w1*src.at<_Tp>(i+fy,j+fx)[k] + w2*src.at<_Tp>(i+fy,j+cx)[k] + w3*src.at<_Tp>(i+cy,j+fx)[k] + w4*src.at<_Tp>(i+cy,j+cx)[k];
                // we are dealing with floating point precision, so add some little tolerance
                dst.at<cv::Vec3b>(i-radius,j-radius)[k] += ((t > src.at<_Tp>(i,j)[k]) && (abs(t-src.at<_Tp>(i,j)[k]) > std::numeric_limits<float>::epsilon())) << n;
                }
            }
        }

image description

2015-05-11 02:28:25 -0600 received badge  Enthusiast
2015-05-10 02:59:11 -0600 commented question local binary pattern with texture classification

I followed Python code to calculate ELBP and set the radius to 2 with 16 neighborhood which gives a pretty good answer for Kullback-Leibler distance (same image as 0). But using Hellinger with this parameter does not seem to work well.

2015-05-09 09:58:03 -0600 commented question local binary pattern with texture classification

I found out I misplaced lbp1 in my normalized function. I am using Kullback-Leibler divergence suggested here (http://xy-27.pythonxy.googlecode.com/...). I will take a look at spatial_histogram, thanks for the lead.

2015-05-09 08:21:00 -0600 asked a question local binary pattern with texture classification

So I tried to do local binary pattern and histogram comparison on my texture. I used the local binary program from here (https://github.com/bytefish/opencv/tr...) and tried to compare the histogram difference for two images, but for some reason the match is really high even when the texture differs a lot. I modified the main.cpp just a little bit so that I can get the histogram comparison value to show. Below is my code. As you can see the result turns out to be 94.48% match, so I would like to know what I am doing wrong so I can improve the result. I am using OLBP. The image below shows histogram and result. I would like to compare with histogram but not feature matching.

int main(int argc, const char *argv[]) {
    int deviceId = 0;
    if(argc > 1)
        deviceId = atoi(argv[1]);

    VideoCapture cap(deviceId);

    if(!cap.isOpened()) {
        cerr << "Capture Device ID " << deviceId << "cannot be opened." << endl;
        return -1;
    }

    // initial values
    int radius = 1;
    int neighbors = 8;

    // windows
    namedWindow("original",CV_WINDOW_AUTOSIZE);
    namedWindow("lbp",CV_WINDOW_AUTOSIZE);

    // matrices used
    Mat test;
    Mat test1;
    Mat frame; // always references the last frame
    Mat dst; // image after preprocessing
    Mat dst1;
    Mat lbp; // lbp image
    Mat lbp1;

    // just to switch between possible lbp operators
    vector<string> lbp_names;
    lbp_names.push_back("Extended LBP"); // 0
    lbp_names.push_back("Fixed Sampling LBP"); // 1
    lbp_names.push_back("Variance-based LBP"); // 2
    int lbp_operator=1;

    bool running=true;
    while(running) {
        //cap >> frame;
        dst = imread("Hist1.jpg", CV_LOAD_IMAGE_GRAYSCALE); //Load as grayscale
        dst1 = imread("Hist3.jpg", CV_LOAD_IMAGE_GRAYSCALE); //Load as grayscale
        //cvtColor(frame, dst, CV_BGR2GRAY);
        //GaussianBlur(test, dst, Size(7,7), 5, 3, BORDER_CONSTANT); // tiny bit of smoothing is always a good idea
        //GaussianBlur(test1, dst1, Size(7,7), 5, 3, BORDER_CONSTANT); // tiny bit of smoothing is always a good idea
        // comment the following lines for original size
        //resize(frame, frame, Size(), 0.5, 0.5);
        //resize(test,dst,Size(), 0.5, 0.5);
        //
        switch(lbp_operator) {
        case 0:
            lbp::ELBP(test, lbp, radius, neighbors); // use the extended operator
            break;
        case 1:
            lbp::OLBP(dst, lbp); // use the original operator
            lbp::OLBP(dst1, lbp1); // use the original operator
            break;
        case 2:
            lbp::VARLBP(dst, lbp, radius, neighbors);
            break;
        }
        // now to show the patterns a normalization is necessary
        // a simple min-max norm will do the job...
        normalize(lbp, lbp, 0, 255, NORM_MINMAX, CV_8UC1);

        Mat lbp_hist, lbp1_hist;

        int histSize[] = {256};

        float s_ranges[] = { 0, 256 };

    const float* ranges[] = { s_ranges };

    // Use the o-th and 1-st channels
    int channels[] = { 0 };

        calcHist( &lbp, 1, channels, Mat(), lbp_hist, 1, histSize, ranges, true, false );
        normalize( lbp1_hist, lbp1_hist, 0, 1, NORM_MINMAX, -1, Mat() );

        calcHist( &lbp1, 1, channels, Mat(), lbp1_hist, 1, histSize, ranges, true, false );
        normalize( lbp_hist, lbp_hist, 0, 1, NORM_MINMAX, -1, Mat() );

        double base_base = compareHist( lbp_hist, lbp1_hist, 0 );

        printf("%f\n",base_base);

        imshow("original", lbp);
        imshow("lbp", lbp1);

        char key = (char) waitKey(0);;

    }
        return 0; // success
}

image description

2015-05-07 11:58:09 -0600 edited question Bag of Features Descriptor

I followed the project until the end (http://www.codeproject.com/Articles/6...). I would like to know how to use the end descriptor to classify the image. How do I know how similar is this descriptor in comparison to the previous training images or dictionary?