Ask Your Question

engine's profile - activity

2020-10-09 15:43:56 -0600 received badge  Nice Question (source)
2018-07-24 03:26:00 -0600 received badge  Famous Question (source)
2017-12-25 00:02:18 -0600 received badge  Popular Question (source)
2017-12-17 02:11:03 -0600 received badge  Famous Question (source)
2017-04-19 13:49:39 -0600 received badge  Notable Question (source)
2016-08-24 06:37:58 -0600 received badge  Popular Question (source)
2016-04-29 16:26:00 -0600 received badge  Famous Question (source)
2015-12-30 04:12:04 -0600 received badge  Notable Question (source)
2015-03-29 09:15:37 -0600 received badge  Popular Question (source)
2015-03-05 05:04:42 -0600 received badge  Notable Question (source)
2014-12-09 13:47:08 -0600 marked best answer Installing cvblobslib on visual sutdio 2010^

Hi! can anybodytell how I can install or use cvbloblib on VS 2010 thanks in advance for your help

2014-08-04 09:30:54 -0600 received badge  Popular Question (source)
2014-02-06 04:34:02 -0600 marked best answer how to use cv::setMouseCallback in a c++ class

Hi ! I'm trying to use the cv::setMouseCallback to crop a frame. it just doesn't work can any body tell the whole program carshes when I use it:

 class Mainthread{
  ......
  cv::Mat m_part;


public :
     static void mouseHandler(int event,int x,int y, int flags,void* param);
     static void draw_box(cv::Mat,cv::Rect);         
     void gettingROI();    
     static cv::Rect theBox;
...
 void MainThread::gettingROI(){
m_part = stream.getframe();
name = "roi";
cv::imshow(name,m_part);
cv::setMouseCallback(name,mouseHandler,&m_part);
 }
 cv::Rect MainThread::theBox =  cv::Rect(0,0,0,0);
 void MainThread::mouseHandler(int event,int x , int y , int flags, void* param){
cv::Mat* pimage = (cv::Mat*) param;
cv::Mat image = * pimage;



switch( event ){
    case CV_EVENT_MOUSEMOVE: 
        if( drawing_box ){
            theBox.width = x-theBox.x;
            theBox.height = y-theBox.y;
        }.............
..........

After @Vladislav suggestion I changed my code, it work now but I have a problem with cv::Rect theBox any idea

2013-09-11 02:06:04 -0600 answered a question Get the color percentage

I don't use Delphi! but to answer your question here's what you can do, split the color planes of your image and convert each of them to the a binary cv::Mat, and then you can run the functioncountNonzero on those 3 binary images, you'll get how many pixel and then you can get the number of pixel in each plane. divide the result by the resolution of you image you'll you percentage. I hope that's possible in Delphi.

2013-09-10 06:11:08 -0600 answered a question opencv starting error

You can't just put 219 code lines and expect people to read it for you ! I just debugged you program I the error is clear you capture device is wrong capture = cvCreateCameraCapture(200); // you have to put for example 0 as an ID and your key variable isn't initialized I put int key =0 and the program will work

2013-09-09 04:49:03 -0600 asked a question findchessboardCorners result

Hi!

I have a chessboard where its height equal to its width, and I need to know how to change for example a recognized chessboard let's say a 3 rows to 3 columns, here a an example of a code a the result it may help you understanding my question :

int main () {
    cv::Mat frame;
    cv::Size board(3,3);
    cv::vector<cv::Point2f> imageCorners;
    cv::VideoCapture cap (0);
    int key =0;

    while(key != 27){
        cap >> frame;
        if(cv::findChessboardCorners(frame,board,imageCorners,CV_CALIB_CB_FILTER_QUADS)){
            cv::drawChessboardCorners(frame,board,imageCorners,true);
            cv::imwrite("stack.jpg",frame);
        }
        cv::imshow("frame",frame);
        key = cv::waitKey(10);
    }

    return 0 ;
}

columns vector

rows vector

2013-08-29 07:19:36 -0600 received badge  Critic (source)
2013-08-27 01:48:37 -0600 answered a question VideoCapture open() won't open second camera

Hi! having two video input devices doesn't mean automatically that their IDs are 0 and 1, did you try to access the second camera alone with the ID 1 ? I have two cameras and here what I've tried and it worked :

int main (){

cv::VideoCapture cap(0), cap2(2);
int key = 0;
cv::Mat frame,frame1;

while(key != 27){
    cap2 >> frame1;
    cap >> frame;
    cv::imshow("0",frame);
    cv::imshow("1", frame1);
    key = cv::waitKey(10);

}
cap.release();
cap2.release();
return 0;
}
2013-08-27 00:47:59 -0600 answered a question Can we use OpenCv in VS 2012 ?

yes I did I'm using OpenCV2.3.6 with VS2012

2013-08-26 02:36:06 -0600 answered a question type and size of calibration pattern for most accurate results

Hi!

for the calibration I think the best thing is use the chessboard, because it's easier and faster to recognize then the circles, and try to use an asymmetric combination meaning a 7x8 or 13x10 etc ... to get the rotation information too. And after running the calibration you'll the calibration error the should as small as possible and it's the case if cover the whole size of your frame!

2013-08-20 04:33:59 -0600 answered a question 2x3 Transformation Matrix

the transformation matrix contain the relationship between the x' and y' in the image coordinate system and the real world coordinate system which is 3 dimensional !

2013-08-14 14:12:28 -0600 answered a question problem with reading image to Mat

I'm using the same version of opencv and VS and I don't have a problem you shohould put your code to be sure that's not the reason of your Problem

2013-08-13 05:41:24 -0600 asked a question Perspective change of vector

Hi!

say I have a source image than I transform to a dst image using getPerspectiveTransform and cv::warpPerspective. after that I have special vector of points in my source image, and I want to get or rather draw them in my dst image , I thought it'll obvious, but I don't this done , to better explain the problem I have a sample with a chessboard:

.................................
transformationMatrix= cv::getPerspectiveTransform(src_Point, quad_pts);
            cv::warpPerspective(src, dst, transformationMatrix, dst.size()/,CV_INTER_LINEAR,cv::BORDER_ISOLATED);

this work fine so Now I've changed the perspective of my src frame. to transform my Points and theen put them in the dst I wrote this small function

std::vector<cv::Point2f> warpStuff(std::vector<cv::Point2f> inputVector , cv::Mat transformationMatrix){
    cv::Matx33f warp = transformationMatrix;
    cv::Point3f homogenous;
    std::vector<cv::Point2f> result;

    for (int k  =0;  k < inputVector.size()-1; k++ ){
        homogenous = warp* inputVector[k];
        result.push_back(cv::Point2f(homogenous.x,homogenous.y));
    }

    return result;
}

when try to draw the result vector in dst I don't get the points in their position ?

here's my source image

the source

and after the transformation, when draw result here' a what I get :

the dst

I think the problem is that cv::warpPerspective is using in addition to the transformation matrix the size of the dst image, I tried to debugg the stuff but I really didn't understand what does it do with this size so I can add this to my function !

any suggestion ?

2013-08-12 08:41:13 -0600 answered a question affine transform coordinate
2013-08-12 05:35:07 -0600 answered a question Changing the perspective using Opencv

I've asked the same question on stackoverflow and I got an answer for those who need it : http://stackoverflow.com/questions/18181012/changing-the-perspective-using-opencv

2013-08-12 02:13:41 -0600 asked a question Changing the perspective using Opencv

I'm working on a project, in which I use a chessboard, the problem that I'm facing, is when I recognize the board I want to crop the part of the frame that contains it and put it "straight", for that I'm using the cv::warpPerspective function, bellow is my code and the result that I get :

int main (){
    cv::Size board(6,4);
    cv::Mat src,result,quad,transformationMatrix;
    std::vector<cv::Point2f> imageCorners;
    std::vector<cv::Point2f> top, bot;



  std::vector<cv::Point2f> not_a_rect_shape;
    cv::VideoCapture cap(0);
    char fileName[20] = "MYROI";
    int index =0;
    int key = 0 ;   
    cap >> src;
    while ( key != 27){
        cap >> src;
        if(cv::findChessboardCorners(src,board,imageCorners,CV_CALIB_CB_FILTER_QUADS)){
            int xMin =imageCorners.at(0).x  ,xMax = imageCorners.at(0).x; 
            int yMin = imageCorners.at(0).y, yMax =imageCorners.at(0).y;
        for (int i  = (imageCorners.size()-1) ; i>0;i--){
                if(xMin > imageCorners.at(i-1).x)
                        xMin = imageCorners.at(i-1).x;
                if(xMax < imageCorners.at(i-1).x)
                    xMax = imageCorners.at(i-1).x;
                if(yMin > imageCorners.at(i-1).y)
                    yMin = imageCorners.at(i-1).y;
                if(yMax < imageCorners.at(i-1).y)
                    yMax = imageCorners.at(i-1).y;
            } 
        cv::Rect  myroi(xMin-5,yMin-5,(xMax-xMin)+5,(yMax-yMin)+5);
        if ( myroi.area() > 0){
            cv::imshow("ROI",(src)(myroi));  
        result = (src)(myroi);
        not_a_rect_shape.clear();
        not_a_rect_shape.push_back(imageCorners[0]);
        not_a_rect_shape.push_back(imageCorners[board.height-1]);
        not_a_rect_shape.push_back(imageCorners[board.area()-board.height-1]);
        not_a_rect_shape.push_back(imageCorners[board.area()-1]);
        std::vector<cv::Point2f> approx;
        cv::approxPolyDP(cv::Mat(not_a_rect_shape),approx,cv::arcLength(cv::Mat(not_a_rect_shape),true)*0.02,true);
        if (approx.size()!=4){
            std::cout << " Not quadrilateral!"<<std::endl;

            not_a_rect_shape.clear();
            approx.clear();

            not_a_rect_shape.push_back(imageCorners[0]);
            not_a_rect_shape.push_back(imageCorners[board.width-1]);
            not_a_rect_shape.push_back(imageCorners[board.area()-board.width-1]);
            not_a_rect_shape.push_back(imageCorners[board.area()-1]);
            cv::approxPolyDP(cv::Mat(not_a_rect_shape),approx,cv::arcLength(cv::Mat(not_a_rect_shape),true)*0.02,true); 
        }

        // center 
        cv::Point2f center(0,0);
        for (int i = 0 ; i <not_a_rect_shape.size(); i++)
                center+= not_a_rect_shape[i];
            center *=( 1./not_a_rect_shape.size()); // the center position 

            top.clear();
            bot.clear();
        // ordering  the  4 points 
        for (int i = 0; i < not_a_rect_shape.size(); i++){
            if (not_a_rect_shape[i].y < center.y)
                top.push_back(not_a_rect_shape[i]);
            else
                 bot.push_back(not_a_rect_shape[i]);
            }
        std::cout << center << std::endl;
        if(top.size()== 2 && bot.size()==2){ 
            cv::Point2f tl = top[0].x > top[1].x ? top[1] : top[0];
            cv::Point2f tr = top[0].x > top[1].x ? top[0] : top[1];
            cv::Point2f bl = bot[0].x > bot[1].x ? bot[1] : bot[0];
            cv::Point2f br = bot[0].x > bot[1].x ? bot[0] : bot[1];
            not_a_rect_shape.clear();
            not_a_rect_shape.push_back(tl);
            not_a_rect_shape.push_back(tr);
            not_a_rect_shape.push_back(br);
            not_a_rect_shape.push_back(bl);

            // Define the destination image
            quad = cv::Mat::zeros(300, 220, CV_8UC3);
            //quad = cv::Mat::zeros(result.rows,result.cols,CV_8UC3);
        // Corners of the destination image
            std::vector<cv::Point2f> quad_pts;
            quad_pts.push_back(cv::Point2f(0, 0));
            quad_pts.push_back(cv::Point2f(quad.cols, 0));
            quad_pts.push_back(cv::Point2f(quad.cols, quad.rows));
            quad_pts.push_back(cv::Point2f(0, quad.rows));
            transformationMatrix= cv ...
(more)
2013-07-30 06:45:11 -0600 commented question ArUco configuration in Visual Studion 2010

yes I got the wrong files so it's my fault

2013-07-30 03:42:10 -0600 commented question ArUco configuration in Visual Studion 2010

@berak yes I tried to use cmake but I don't have the source files so I don't know can I do it , I downloaded :aruco_msvc10.zip from http://sourceforge.net/projects/aruco/files/1.2.4/ and I got .dll and .lib and .h files so I can only setup the project but I LNK2019 error

2013-07-30 03:08:12 -0600 asked a question ArUco configuration in Visual Studion 2010

Hi!

I have an opencv project, and I want to add some functionalty of ArUco to it, my problem is that I don't find any explanation about it configuration in VS2010, I was wondering if somebody know how to this ? thanks in advance for your help!

2013-07-25 06:33:29 -0600 commented answer an Alternative for cvGet2D()

thanks a lot for your help

2013-07-25 05:52:54 -0600 commented answer an Alternative for cvGet2D()

to be honest I don't get it ?? the type of tdst is 13 so how can get the values of p1 ??

2013-07-25 05:35:21 -0600 commented answer Runnig cv::warpPerspective on points

I can get the back transformation with cv::warpPerspective, but how can't to that only for a set points ?

2013-07-25 05:31:51 -0600 asked a question an Alternative for cvGet2D()

Hi! I have a problem and I found i solution, but in c since I'm using c++ for my program , I changed the code but I can't change following part:

CvPoint pDst; // cv::Point pdst; CvScalar p1; // cv::Scalar p1;

p1=cvGet2D(&tdst,0,0); / / how can I change this ???

thanks in advance ? ?

2013-07-25 05:19:51 -0600 commented answer Runnig cv::warpPerspective on points

this means that what I'm trying to do isn't possible ? ???

2013-07-25 04:52:36 -0600 commented answer Runnig cv::warpPerspective on points

I tried your suggestion, but the result is always 0 ?? have a look at the update

2013-07-25 02:55:45 -0600 asked a question Runnig cv::warpPerspective on points

Hi !

I'm running the cv::warpPerspective() function on a image and what to get the position of the some points of result image the I get in the source image, here how far I came :

    cv::Point2f srcQuad[4],dstQuad[4];
    cv::Mat warpMatrix;
    cv::Mat inverseMatrix;
    cv::Mat src, dst,src2;
    src = cv::imread("blue.jpg",1);
    srcQuad[0].x = 0; //src Top left
    srcQuad[0].y = 0;
    srcQuad[1].x = src.cols - 1; //src Top right
    srcQuad[1].y = 0;
    srcQuad[2].x = 0; //src Bottom left
    srcQuad[2].y = src.rows - 1;
    srcQuad[3].x = src.cols -1; //src Bot right
    srcQuad[3].y = src.rows - 1;
    dstQuad[0].x = src.cols*0.05; //dst Top left
    dstQuad[0].y = src.rows*0.33;
    dstQuad[1].x = src.cols*0.9; //dst Top right
    dstQuad[1].y = src.rows*0.25;
    dstQuad[2].x = src.cols*0.2; //dst Bottom left
    dstQuad[2].y = src.rows*0.7;
    dstQuad[3].x = src.cols*0.8; //dst Bot right
    dstQuad[3].y = src.rows*0.9;
    std::vector<cv::Point2f> mySrcPoints;
    cv::Mat mydst;

    mySrcPoints.push_back(cvPoint(5,10));
    mySrcPoints.push_back(cvPoint(50,20));     
    cv::rectangle(
            src,
            cv::Point(5,10),
            cv::Point(20,30),
            cv::Scalar(255,255,255)
       );        
    warpMatrix =cv::getPerspectiveTransform(srcQuad,dstQuad);
    cv::warpPerspective(cv::Mat(mySrcPoints),mydst,warpMatrix,src.size(),CV_WARP_INVERSE_MAP);
    for( int r = 0 ; r < mydst.rows ; ++r )
{
    for( int c = 0 ; c < mydst.cols ; ++c )
    {
        if(mydst.at< float >( r, c )!=0)
         std::cout << "Point at " << r << "," << c << " is wrap at " << mydst.at< float >( r, c ) << std::endl;
    }
}

    //cv::imshow("my dst ", mydst);
    //cv::Point x = converting(poi,warpMatrix);
    //std::cout <<"Converting for the first time  \n "<<x<< std::endl;
    cv::invert(warpMatrix,inverseMatrix);
    //cv::Point y = converting(poi,inverseMatrix);
    //std::cout <<"Converting for the second time  \n "<<y<< std::endl;
    cv::warpPerspective(src,dst,warpMatrix,src.size());
    cv::imshow("source", src);
    cv::imshow("destination", dst);
    cv::warpPerspective(dst,src2,warpMatrix,dst.size(),CV_WARP_INVERSE_MAP);
    cv::imshow("srouce 2 ", src2);
    cv::waitKey();
    return 0;

my problem is that if I select a point from dst how can get its coordinates in * src or src2 * since the cv::warpPerspective function doesn't take cv::Point as parameter ??

2013-07-24 03:54:27 -0600 asked a question Getting back to the original coordinates from a warped Image

I have four corners extracted from a image,

std::vector<cv::Point2f> ecken;
ecken.push_back(corners[0]);
ecken.push_back(corners[size.height-1]);
ecken.push_back(corners[size.area()-size.height-1]);
ecken.push_back(corners[size.area()-1]);

they are warped in to a second image:

quad_pts.push_back(cv::Point2f(0, 0));
            quad_pts.push_back(cv::Point2f(quad.cols, 0));
            quad_pts.push_back(cv::Point2f(quad.cols, quad.rows));
            quad_pts.push_back(cv::Point2f(0, quad.rows));

    // Get transformation matrix


      cv::Mat transmtx = cv::getPerspectiveTransform(ecken, quad_pts);
cv::warpPerspective(src, quad, transmtx, quad.size(),1);

I want to go back to the original image from the result that I get in quad, these what I've tried:

cv::Mat trans  = cv::getPerspectiveTransform(quad_pts,ecken );
        cv::perspectiveTransform(quad,test,trans);

and it didn't work !! any idea ??

2013-07-15 05:12:33 -0600 commented answer how to find a part of a chessboard

any idea Idea how to get their positions ??

2013-07-15 04:46:37 -0600 commented answer how to find a part of a chessboard

so you mean if I want to use this function I can't get a part of the detected chessboard

2013-07-15 04:13:59 -0600 asked a question how to find a part of a chessboard

Hi ! I want to use the cv::findChessboard() function to calibrate my camera. let'S say I've a 4x5 chessboard how can I get information abot the corners if only a a part of my chessboard has been detected say 3x4 or 3x5 or 4x4 etc.

thanks in advance for your help