Ask Your Question

andrea's profile - activity

2020-10-04 08:29:50 -0600 received badge  Good Question (source)
2019-09-05 09:49:56 -0600 received badge  Notable Question (source)
2018-01-01 01:05:11 -0600 received badge  Nice Question (source)
2017-08-01 13:57:33 -0600 received badge  Popular Question (source)
2017-02-06 08:48:07 -0600 received badge  Notable Question (source)
2016-10-23 10:54:41 -0600 received badge  Famous Question (source)
2015-07-08 05:42:00 -0600 received badge  Popular Question (source)
2015-03-18 18:51:33 -0600 received badge  Nice Question (source)
2015-02-25 08:20:40 -0600 received badge  Notable Question (source)
2014-12-03 09:36:33 -0600 received badge  Famous Question (source)
2014-09-02 16:45:41 -0600 received badge  Famous Question (source)
2014-07-20 21:38:48 -0600 received badge  Popular Question (source)
2014-01-13 15:07:02 -0600 received badge  Good Question (source)
2013-12-11 08:38:09 -0600 received badge  Notable Question (source)
2013-11-18 15:31:25 -0600 received badge  Notable Question (source)
2013-09-16 02:36:39 -0600 received badge  Famous Question (source)
2013-07-01 15:34:42 -0600 received badge  Popular Question (source)
2013-06-04 23:35:58 -0600 received badge  Popular Question (source)
2013-03-15 08:06:37 -0600 received badge  Notable Question (source)
2013-01-11 02:49:40 -0600 received badge  Popular Question (source)
2012-10-18 06:03:41 -0600 asked a question problem with Orb matching

Hi to all! i try to use Orb feature for object detection... i use this code:

int numKeyPoints = 200;
std::vector<KeyPoint> keypoints_1,keypoints_2;
OrbFeatureDetector detector(numKeyPoints);
detector.detect( img_1, keypoints_1 );
detector.detect( img_2, keypoints_2 );
OrbDescriptorExtractor extractor;
Mat descriptors_1,descriptors_2;
extractor.compute( img_1, keypoints_1, descriptors_1 );
extractor.compute( img_2, keypoints_2, descriptors_2 );
BFMatcher matcher(Hamming);
std::vector< DMatch > matches;
matcher.match( descriptor_1, descriptor_2, matches );

but i have this error:

request for member 'match' in 'matcher', which is of non-class type 'cv::BFMatcher ()(cv::Hamming)'

I don't understand where is the error....

thanks!!

2012-10-08 13:55:13 -0600 asked a question warpperspective with iplimage

hi!

there are a method for usig warpperspective with the iplimage?

i try : warpPerspective(img_frame,crop,Homo.inv(DECOMP_LU),cvGetSize(img_temp));

where img_frame and crop are Iplimage* but i give me an error

error: invalid initialization of reference of type 'const cv::_InputArray&' from expression of type 'IplImage*' /opt/local/include/opencv2/imgproc/imgproc.hpp:540: error: in passing argument 1 of 'void cv::warpPerspective(const cv::_InputArray&, const cv::_OutputArray&, const cv::_InputArray&, cv::Size, int, int, const cv::Scalar&)'

2012-10-08 11:40:43 -0600 commented answer convert mat to iplimage

yes...i tried this method but don't work...

2012-10-08 11:37:36 -0600 commented question convert mat to iplimage

I try to use VideoWriter::write... I create

VideoWriter writer2("video_rect_out2.avi", CV_FOURCC('M','J','P','G'), fps, cvSize(img_template.cols, img_template.rows), true);

and after i use

writer2 << img_template;

but at the end the video result is empty...

2012-10-08 11:09:20 -0600 answered a question convert mat to iplimage

mmmm when i use this iplimage for the stream of the video tha video don't contain any image...

2012-10-08 09:57:00 -0600 asked a question convert mat to iplimage

hi to all!

i have a simple question...can i convert a Mat imege into a Iplimage* ???

i need to insert the Mat image into a video,and the cvWriteFrema need a IplImage...

thanks :)

2012-10-08 02:51:33 -0600 asked a question Problem in create a video output

Hi to all!

I have a problem with the creation of a output video. In my program I take a video from the input and I recognize if there is some specific object (in this case the screen of a smartphone) and then I create the rectified image of the frame, so I have a new image with the video of the smartphone...

I must create the video with the image of the rectification of the screen of the smartphone... But at the end I have only a videofile of 8Kb... I think that the writer doesn't insert the image in the stream....

this is the definition of the writer:

// capture properties
frameH = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
frameW = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
fps    = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
writer = cvCreateVideoWriter("video_rect_out.avi", CV_FOURCC('P','I','M','1'), fps, 
                             cvSize(frameW,frameH), isColor);

and this is the insert of the image in the stream (img_video_stream is the image of the rectification of the screen):

img_out = new IplImage(img_video_stream);
cvWriteFrame(writer, img_out);
cvShowImage("Rettificato out", img_out);

someone can have some idea of the problem?

2012-08-31 07:57:41 -0600 received badge  Nice Question (source)
2012-08-30 03:48:19 -0600 answered a question homography for cordinates of poins

i already try

i write: perspectiveTransform(keypoints[i],temp,inv)

but he give me an error : invalid initialization of reference of type 'const cv::_InputArray&' from expression of type 'cv::KeyPoint'

2012-08-28 10:04:42 -0600 asked a question homography for cordinates of poins

is it possible to apply a homography to the coordinates of a point?

for example in his code:

double X;
double Y;
std::vector<KeyPoint> key_filtered;
for( int i=0; i<(int)keypoints.size(); i++)
{
        double x = keypoints[i].pt.x, y = keypoints[i].pt.y;


        if((X >= corner[0].x && X <= corner[1].x) && (Y >= corner[0].y && Y <= corner[2].y)){
                key_filtered[j]=keypoints[i];
                j++;
        }
    }

i want apply the homography "inv" to "x" and "y"....

2012-08-09 08:31:14 -0600 answered a question apply homography to image

thanks!

can you give me an example of the use of warpPerspective()? i try warpPerspective(img_source,img_dest,H,img_dest.size)

but i give me an error

main.cpp:211: error: conversion from 'cv::Mat::MSize' to non-scalar type 'cv::Size' requested

2012-08-09 05:55:35 -0600 asked a question apply homography to image

hi to all!

i have a little problem...if i have a homography H and an image (call it img_source)....how can i apply this homography to the image? i try:

perspectiveTransform( img_source, img, H);

but when i run the program i give me an error....

thank a lot!

2012-08-02 12:13:47 -0600 asked a question good result or bad result for findHomography

I read that for finding that the homography is good or bad thare are 2 solution:

  1. Compute the determinant of the homography, and see if it's too close to zero for comfort.

  2. Even better, compute its SVD, and verify that the ratio of the first-to-last singular value is sane (not too high). Either result will tell you whether the matrix is close to singular.

Is this true? and there is a method to calculate the SVD in opencv?

2012-08-01 08:27:12 -0600 answered a question object detection using SURF & FLANN

thanks!

i try to do some debug in my code and i have verify that the Homography H is wrong for some frames! the exact H is :

H = [0.6487030067242824, -0.08631426465278198, 261.6879493611227; 0.01335918943588019, 0.7381261562725441, 68.20078368844314; -0.0001412237402441972, -5.520086932186027e-06, 1]

and for some frames there is:

H = [-2.57857982218806, 0.3892895299010169, 394.0872195148755; -0.7676881270794974, 0.2898285736196523, 107.9234724910376; -0.006545151477964493, 0.0009948206740805412, 1]

now i tries with your method but i am not sure that i can change the SURF with the ORB....in this case some one know a method for correct the wrong Homography??????

thanks a lot!!!

2012-08-01 05:37:46 -0600 received badge  Student (source)
2012-07-31 14:44:35 -0600 commented answer crop image

sorry have another question... but if i want to crop a region that is not a rect? for example i have 4 point (the vertices) and i want the region delimited by this vertices (almost of the time is a rectangle but not always)

2012-07-31 14:40:04 -0600 commented answer crop image

thanks :)

2012-07-31 14:18:13 -0600 asked a question crop image

hi!

someone know how to use crop for the image?

for example i have one image i want to show a part of this image...

i read that there are the cvRect and cvSetImageROI.....

thanks a lot :)

2012-07-31 09:55:20 -0600 received badge  Editor (source)
2012-07-31 09:55:20 -0600 edited question object detection using SURF & FLANN

hi!

i write one program for finding one object in a image file in a video . i read the istruction in the opencv manual and i use the SURF and the FLANN matcher. the program draw lines between the corners in the mapped object in the video file. the problem is that in some frame the lines are not present or lines draw a strange figure.

for example...this is the correct output

image description

and this is the wrong result for some frame

image description

image description

this is the code for the program:

void surf_detection(Mat img_1,Mat img_2); /** @function main */

int main( int argc, char** argv )
{

 int i;
 int key;

 CvCapture* capture = cvCaptureFromAVI("video.MPG");// Read the video file

 if (!capture){

     cout <<" Error in capture video file" << endl;
     return -1;
 }

 Mat img_template = imread("template.png"); // read template image

CvVideoWriter *writer = 0;
int isColor = 1;

//Get capture device properties
cvQueryFrame(capture); // this call is necessary to get correct 
                       // capture properties
int frameH    = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
int frameW    = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
int fps       = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
int numFrames = (int) cvGetCaptureProperty(capture,  CV_CAP_PROP_FRAME_COUNT);

writer=cvCreateVideoWriter("out.avi",CV_FOURCC('P','I','M','1'),
                           fps,cvSize(frameW,frameH),isColor);

IplImage* img = 0; 

for(i=0;i<numFrames;i++){
  cvGrabFrame(capture);          // capture a frame
  img=cvRetrieveFrame(capture);  // retrieve the captured frame

  printf("Frame n° %d \n", i );

  surf_detection (img_template,img);

  cvWriteFrame(writer,img);      // add the frame to the file
  cvShowImage("mainWin", img); 
  key=cvWaitKey(20);           // wait 20 ms

}
 cvReleaseVideoWriter(&writer);

 //waitKey(0); // Wait for a keystroke in the window
 return 0;
 }

/** @function surf_detection */
/** USE OF FUNCTION*/
/** param1: immagine del template*/
/** param2: immagine estratta dal video*/
void surf_detection(Mat img_1,Mat img_2)
{ 

if( !img_1.data || !img_2.data )
{ 
    std::cout<< " --(!) Error reading images " << std::endl; 

}




//-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 400;
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints_1, keypoints_2;

std::vector< DMatch > good_matches;

do{ 

detector.detect( img_1, keypoints_1 );
detector.detect( img_2, keypoints_2 );

//-- Draw keypoints

Mat img_keypoints_1; Mat img_keypoints_2;
drawKeypoints( img_1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
drawKeypoints( img_2, keypoints_2, img_keypoints_2, Scalar::all(-1), DrawMatchesFlags::DEFAULT );

//-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
Mat descriptors_1, descriptors_2;
extractor.compute( img_1, keypoints_1, descriptors_1 );
extractor.compute( img_2, keypoints_2, descriptors_2 );


//-- Step 3: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_1, descriptors_2, matches );
double max_dist = 0; 
double min_dist = 100;

//-- Quick calculation of max and min distances between keypoints
for( int i = 0; i < descriptors_1.rows; i++ )
{ 
    double dist = matches[i].distance;
if( dist < min_dist )
    min_dist = dist;
if( dist > max_dist ) 
    max_dist = dist;
}

printf("-- Max dist : %f \n", max_dist );
printf("-- Min dist : %f \n", min_dist );

//-- Draw only "good" matches (i.e. whose distance is less than 2*min_dist )
//-- PS.- radiusMatch can also be used here.



for( int i = 0; i < descriptors_1.rows; i++ )
{ 
    if( matches[i].distance < 2*min_dist )
        { 
                good_matches.push_back( matches[i]);
        }
}

}while(good_matches.size()<100);

//-- Draw only "good" matches
Mat img_matches;
drawMatches( img_1, keypoints_1, img_2, keypoints_2,good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );

//-- Localize the ...
(more)