Ask Your Question

xinyiman's profile - activity

2016-06-04 14:59:12 -0600 received badge  Student (source)
2016-03-01 08:38:25 -0600 asked a question face recognition

Who tells me where to find the source (C ++) of a program to do face recognition from webcam. Including training needed to recognize faces in the video. I would not lose too much time because looking on the internet it seems that many have already done something similar. So as to devote to its integration in a project of mine. Thank you

2016-02-28 10:27:03 -0600 commented answer eliminating edges

There's still one thing I do not understand, the picture is as I will, without borders. But tesseract can not read it properly. The same edited image with ImageMagick works.

The edited image with ImageMagick can be found here: http://forum.ubuntu-it.org/download/f...

the results are the same, but I do not understand why a tesseract to read it properly and the other not.

Solution?!

2016-02-28 09:22:26 -0600 commented answer eliminating edges

it's perfect. thank you very much

2016-02-28 08:04:55 -0600 commented answer eliminating edges

@sturkmen: I do not understand what you mean. @Tetragramm: I reversed as you say. From Mat::ones(8,1,CV_8UC1) to Mat::ones(1,8,????) but I do not know what to put in the place of CV_8UC1

2016-02-26 16:54:47 -0600 commented answer eliminating edges

I did some tests but do not understand how.

2016-02-26 16:04:26 -0600 commented answer eliminating edges

please example?!

2016-02-26 15:47:39 -0600 commented answer eliminating edges

ok , with CV_REDUCE_AVG it's ok. But to remove the vertical line?!

2016-02-26 15:36:56 -0600 commented answer eliminating edges

pi@raspberrypi:~/app $ g++ linee.c++ -o linee -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect linee.c++: In function ‘int main(int, char**)’: linee.c++:17:35: error: ‘REDUCE_AVG’ was not declared in this scope reduce( eroded, reduced_w, 1, REDUCE_AVG );

2016-02-26 13:46:51 -0600 asked a question eliminating edges

Hello guys, who tells me how to remove the edges and the center line? So as to have only the characters?

Thank you

https://03054610326450256607.googlegr...

2016-02-14 12:41:11 -0600 commented answer Don't read my rectangle

Ok, I went ahead. Now fill. And it works, manages to draw me the right rectangles.

But now I have a doubt. This is the function that draws rectangles

static void drawSquares( Mat& image, const vector<vector<point> >& squares ) { for( size_t i = 0; i < squares.size(); i++ ) { const Point* p = &squares[i][0]; int n = (int)squares[i].size(); polylines(image, &p, &n, 1, true, Scalar(0,255,0), 3/, LINE_AA/); }

//imshow(wndname, image);

}

How do I get to print the screen coordinates of these rectangles that draws?

2016-02-14 12:19:53 -0600 commented answer Don't read my rectangle

The problem is, i have a open cv 2, imgcodecs.hpp is insert into 3.

I have delete the include imgcodecs.hpp and when i compiled squares project return this error:

g++ squares.c++ -o squares -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect >> app.txt squares.c++: In function ‘void drawSquares(cv::Mat&, const std::vector<std::vector<cv::point_<int> > >&)’: squares.c++:135:63: error: ‘LINE_AA’ was not declared in this scope polylines(image, &p, &n, 1, true, Scalar(0,255,0), 3, LINE_AA);

why? Sorry to my terrible english

2016-02-12 03:32:43 -0600 commented answer Don't read my rectangle

The problem is that I do not find. I have given the command of ubuntu

sudo apt-get install libopencv-dev

but I did not get the desired result. Why?

2016-02-11 15:25:40 -0600 commented answer Don't read my rectangle

I tried to compile the project:

https://github.com/Itseez/opencv/blob...

But i have an error. Why? $ g++ squares.c++ -o squares -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect squares.c++:7:33: fatal error: opencv2/imgcodecs.hpp: File o directory non esistente #include "opencv2/imgcodecs.hpp" ^ compilation terminated.

2016-02-11 15:23:48 -0600 received badge  Enthusiast
2016-02-10 09:05:09 -0600 asked a question Don't read my rectangle

I adapted this code to read the white rectangle with the word 23-1965

But, it does not detect it sees a lot of other side dishes, but not what interests me. Who tells me where I'm wrong? Also attach the image to be processedimage description

/**
 * Simple shape detector program.
 * It loads an image and tries to find simple shapes (rectangle, triangle, circle, etc) in it.
 * This program is a modified version of `squares.cpp` found in the OpenCV sample dir.
 */
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <cmath>
#include <iostream>

using namespace std;

/**
 * Helper function to find a cosine of angle between vectors
 * from pt0->pt1 and pt0->pt2
 */
static double angle(cv::Point pt1, cv::Point pt2, cv::Point pt0)
{
    double dx1 = pt1.x - pt0.x;
    double dy1 = pt1.y - pt0.y;
    double dx2 = pt2.x - pt0.x;
    double dy2 = pt2.y - pt0.y;
    return (dx1*dx2 + dy1*dy2)/sqrt((dx1*dx1 + dy1*dy1)*(dx2*dx2 + dy2*dy2) + 1e-10);
}

/**
 * Helper function to display text in the center of a contour
 */
void setLabel(cv::Mat& im, const std::string label, std::vector<cv::Point>& contour)
{
    int fontface = cv::FONT_HERSHEY_SIMPLEX;
    double scale = 0.4;
    int thickness = 1;
    int baseline = 0;

    cv::Size text = cv::getTextSize(label, fontface, scale, thickness, &baseline);
    cv::Rect r = cv::boundingRect(contour);

    cv::Point pt(r.x + ((r.width - text.width) / 2), r.y + ((r.height + text.height) / 2));
    cv::rectangle(im, pt + cv::Point(0, baseline), pt + cv::Point(text.width, -text.height), CV_RGB(255,255,255), CV_FILLED);
    cv::putText(im, label, pt, fontface, scale, CV_RGB(0,0,0), thickness, 8);
}

int main(int argc, char** argv)
{
    //cv::Mat src = cv::imread("polygon.png");
    cv::Mat src = cv::imread(argv[1]);
    if (src.empty())
        return -1;

    // Converti in scala di grigi
    cv::Mat gray;
    cv::cvtColor(src, gray, CV_BGR2GRAY);

    // Utilizzare Canny invece di soglia per la cattura di piazze con ombreggiatura gradiente
    cv::Mat bw;
    cv::Canny(gray, bw, 0, 50, 5);

    // Trova contorni
    std::vector<std::vector<cv::Point> > contours;
    cv::findContours(bw.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);   

    std::vector<cv::Point> approx;
    cv::Mat dst = src.clone();


    for(unsigned int l=0;l<contours.size();l++)
    {

        if (contours[l].size() == 4 /*&& contours[l].size() <= 6*/)
        {

                //cout << "# of contour points: " << contours[l].size() << endl ;
            cout << endl ;
                for(unsigned int k=0;k<contours[l].size();k++)
                {
                //cout << "Point(x,y)=" << contours[l][k] << endl;
                cout << contours[l][k] << ";";
                }
                //cout << " Area: " << contourArea(contours[l]) << endl;
        }
    }

    //cv::imshow("src", src);
    //cv::imshow("dst", dst);
    cv::waitKey(0);
    return 0;
}
2016-02-10 09:00:23 -0600 commented question webcam question

Thank you :)

2016-02-07 11:49:46 -0600 asked a question webcam question

Hello, I bought a new web cam and I made this little program that takes one frame and saves it to a file passed to the parameter.

I have only one problem, the camera is 8 MP but the picture I take is of low resolution: 640x480

How do I tell it to use a higher resolution?

Thank you

My code

#include "opencv2/opencv.hpp" using namespace cv; int main(int argc, char** argv) { VideoCapture cap;

if(!cap.open(0))
{
    return 0;
}else
{
      Mat frame;
      cap >> frame;
      if( frame.empty() ) 
  {

      }else
  {
    imwrite( argv[1], frame );
  }
}

return 0;

}

2016-02-06 12:27:08 -0600 commented question coordinate and dimension of rectangle

So does it work? Well, then I expand the range. Thank you, there is a tool that allows passatagli the image to define the range that I need?

2016-02-06 12:14:29 -0600 commented question coordinate and dimension of rectangle

Hello, I tried to do what you told me. Except that the result is always all black. How do I see what I do?

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

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

include <cmath>

include <iostream>

using namespace std;

int main(int argc, char** argv) { //cv::Mat src = cv::imread("polygon.png"); cv::Mat src = cv::imread(argv[1]); if (src.empty()) return -1;

std::vector<cv::Point> approx;
cv::Mat dst = src.clone();


    cv::Mat mask; // specify the range of colours that you want to include, you can play with the borders here
cv::Scalar lowerb = cv::Scalar(250, 125, 38);
cv::Scalar upperb = cv::Scalar(255, 129, 42);
    cv::inRange(dst, lowerb, upperb, mask); // if the frame has any orange pixel, this will be painted in the mask as wh
2016-02-06 01:23:47 -0600 commented question coordinate and dimension of rectangle

You know tell me a tutorial? Or One example?

2016-02-05 09:54:23 -0600 asked a question HoughLines questions

Hello guys, I'm trying to understand why the transform of Hough It does not detect the lines that make up the orange plate with inside the numbers: 2251073 image description

Where am I wrong?

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main()
{
    Mat src = imread("caio.jpg", 0);

    Mat dst, cdst;
    Canny(src, dst, 50, 200, 3); 
    cvtColor(dst, cdst, CV_GRAY2BGR); 

    vector<Vec2f> lines;
    // detect lines
    HoughLines(dst, lines, 1, CV_PI/180, 150, 0, 0 );

    // draw lines
    for( size_t i = 0; i < lines.size(); i++ )
    {
        float rho = lines[i][0], theta = lines[i][1];
        Point pt1, pt2;
        double a = cos(theta), b = sin(theta);
        double x0 = a*rho, y0 = b*rho;
        pt1.x = cvRound(x0 + 1000*(-b));
        pt1.y = cvRound(y0 + 1000*(a));
        pt2.x = cvRound(x0 - 1000*(-b));
        pt2.y = cvRound(y0 - 1000*(a));
        line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA);
    }

    imshow("source", src);
    imwrite( "binary.jpg", cdst );
    imshow("detected lines", cdst);

    waitKey();
    return 0;
}
2016-02-05 06:58:48 -0600 commented question coordinate and dimension of rectangle

I thank you for the suggestion, but I do not know how to do. I'm not very handy with opencv, there I'm getting closer now!

2016-02-03 23:05:30 -0600 asked a question coordinate and dimension of rectangle

Hello guys, I apologize for my bad English. I have a problem. I found this source.

It works, because it identifies the rectangles that make up the picture. Only that I should extract from the each rectangle to analyze their content with tesseract.

I thought about putting in a file the coordinates of each rectangle and its dimensions (height and width). So then the process with another program on purpose. I just do not understand how. Who tells me how to do it?

My use is to isolate the only part of the picture of the orange plate.image description to read a 2251073.

My code attachment

/** * Simple shape detector program. * It loads an image and tries to find simple shapes (rectangle, triangle, circle, etc) in it. * This program is a modified version of squares.cpp found in the OpenCV sample dir. */

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

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

include <cmath>

include <iostream>

using namespace std;

/* * Helper function to find a cosine of angle between vectors * from pt0->pt1 and pt0->pt2 */ static double angle(cv::Point pt1, cv::Point pt2, cv::Point pt0) { double dx1 = pt1.x - pt0.x; double dy1 = pt1.y - pt0.y; double dx2 = pt2.x - pt0.x; double dy2 = pt2.y - pt0.y; return (dx1dx2 + dy1dy2)/sqrt((dx1dx1 + dy1dy1)(dx2dx2 + dy2dy2) + 1e-10); }

/** * Helper function to display text in the center of a contour */ void setLabel(cv::Mat& im, const std::string label, std::vector<cv::point>& contour) { int fontface = cv::FONT_HERSHEY_SIMPLEX; double scale = 0.4; int thickness = 1; int baseline = 0;

cv::Size text = cv::getTextSize(label, fontface, scale, thickness, &baseline);
cv::Rect r = cv::boundingRect(contour);

cv::Point pt(r.x + ((r.width - text.width) / 2), r.y + ((r.height + text.height) / 2));
cv::rectangle(im, pt + cv::Point(0, baseline), pt + cv::Point(text.width, -text.height), CV_RGB(255,255,255), CV_FILLED);
cv::putText(im, label, pt, fontface, scale, CV_RGB(0,0,0), thickness, 8);

}

int main(int argc, char** argv) { //cv::Mat src = cv::imread("polygon.png"); cv::Mat src = cv::imread(argv[1]); if (src.empty()) return -1;

// Converti in scala di grigi
cv::Mat gray;
cv::cvtColor(src, gray, CV_BGR2GRAY);

// Utilizzare Canny invece di soglia per la cattura di piazze con ombreggiatura gradiente
cv::Mat bw;
cv::Canny(gray, bw, 0, 50, 5);

// Trova contorni
std::vector<std::vector<cv::Point> > contours;
cv::findContours(bw.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);   

std::vector<cv::Point> approx;
cv::Mat dst = src.clone();


//Al momento il cuore del mio algoritmo, mette dei contorni così spessi da  coprire tutto ciò che non è un
cv::drawContours(dst, contours, -1, (0,255,0), 3);  

for (int i = 0; i < contours.size(); i++)

{ // Contorno approssimativo con una precisione proporzionale // al perimetro contorno cv::approxPolyDP(cv::Mat(contours[i]), approx, cv::arcLength(cv::Mat(contours[i]), true)*0.02, true);

// Salta piccole o non-convesse oggetti if (std::fabs(cv::contourArea(contours[i])) < 100 || !cv::isContourConvex(approx)) continue;

if (approx.size() == 3 ...

(more)