Ask Your Question

shruti.arya's profile - activity

2017-08-05 07:56:17 -0600 received badge  Famous Question (source)
2016-06-21 06:35:30 -0600 received badge  Notable Question (source)
2016-03-24 04:15:54 -0600 received badge  Popular Question (source)
2015-05-25 04:47:02 -0600 answered a question Detection of planar objects

Hey @berak, Can you tell me if opencv requires some particular kind of image ?

I cannot find the reason behind the errors :-

  1. Assertion failed (type == B.type() && (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2))
  2. Assertion failed ((type == CV_8U && dtype == CV_32S) || dtype == CV_32F)

Please help me with this too...

2015-05-25 04:45:21 -0600 received badge  Enthusiast
2015-05-22 03:29:28 -0600 commented question Detection of planar objects

Since I have faced a lot of problems in setting up OpenCV for Windows 7, I ended up writing a blog describing the process. You may find it at http://techieshruti.blogspot.in/2015/... and help others too. Thanks, Shruti

2015-05-21 05:51:50 -0600 commented question Detection of planar objects

And BFMatcher gives the error : Assertion failed ((type == CV_8U && dtype == CV_32S) || dtype == CV_32F) in batchDistance, file C:\opencv\opencv-master\opencv-master\modules\core\src\stat.cpp, line 3662 for images not having 32-bit depth.

Even for some images, it works. And for some, it gives this error.

Does it require any special kind of image ? Or there is something else...

I have also tried with images graf1.png and graf3.png. But, the error is same...

Can you please help me with this @berak ?

2015-05-21 05:32:58 -0600 commented question Detection of planar objects

This time, when I am using AKAZE, issues I am facing are : 1. It's dealing with images of 32-bit depth & for others, its giving error : Assertion failed (type == B.type() && (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2)) in gemm, file C:\opencv\opencv-master\opencv-master\modules\core\src\matmul.cpp, line 893 2. Even when I crop a part of image, it isn't finding any matches :/

I am using the image - http://nullcandy.com/wp-content/uploa...

2015-05-21 04:59:12 -0600 commented question Detection of planar objects

@berak, And by the way...saliency compiled w/o giving errors :) However, datasets threw an error.

2015-05-21 04:50:14 -0600 commented question Detection of planar objects

Okay, so now on compilation, 3 errors are still left : error: 'BruteForceMatcher' was not declared in this scope BruteForceMatcher<l2<float> > matcher;

error: expected primary-expression before '>' token BruteForceMatcher<l2<float> > matcher;

error: 'matcher' was not declared in this scope BruteForceMatcher<l2<float> > matcher;

What shall I do for BruteForceMatcher ?

2015-05-21 03:33:58 -0600 commented question Detection of planar objects

I am using cmake-gui. I just entered path for contrib/modules. On executing mingw32-make install, the issues coming are :

  1. warning: ignoring #pragma warning [-Wunknown-pragmas]

    pragma warning( disable : 4267 )

  2. In file included from C:/opencv1/opencv_contrib-master/opencv_contrib-master/mod ules/line_descriptor/src/precomp.hpp:72:0, from C:\opencv1\build\x86\mingw\modules\line_descriptor\opencv_ line_descriptor_pch_dephelp.cxx:1: C:/opencv1/opencv_contrib-master/opencv_contrib-master/modules/line_descriptor/s rc/bitops.hpp:49:21: fatal error: intrin.h: No such file or directory

    include <intrin.h>

How to get rid of them ?

2015-05-21 01:39:18 -0600 received badge  Editor (source)
2015-05-21 01:30:36 -0600 asked a question Detection of planar objects

I am trying to do feature extraction using C++ API. For this, I am using http://docs.opencv.org/ref/master/dd/... as reference.

The code I have written is :

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv/cv.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/calib3d.hpp>
using namespace cv;

#include <iostream>
#include <stdio.h>
using namespace std;

Mat img; Mat templ;
int main(int, char** argv)
{
    templ = cv::imread("C:/Users/.../workspace/FeatureDetectionCPP/src/temp.jpg", IMREAD_GRAYSCALE);
    img = cv::imread("C:/Users/.../workspace/FeatureDetectionCPP/src/image.jpg", IMREAD_GRAYSCALE);

    if(templ.empty())
    {
        cout<<"Empty template";
    }

    if(img.empty())
    {
        cout<<"Empty image";
    }

    Ptr<Feature2D> surf = SURF::create();
    vector<KeyPoint> keypoints1;
    Mat descriptors1;
    surf->detectAndCompute(img, Mat(), keypoints1, descriptors1);

    Ptr<Feature2D> surf1 = SURF::create();
    vector<KeyPoint> keypoints2;
    Mat descriptors2;
    surf1->detectAndCompute(templ, Mat(), keypoints2, descriptors2);

    // matching descriptors
    BruteForceMatcher<L2<float> > matcher;
    vector<DMatch> matches;
    matcher.match(descriptors1, descriptors2, matches);

    // drawing the results
    namedWindow("matches", 1);
    Mat img_matches;
    drawMatches(templ, keypoints1, img, keypoints2, matches, img_matches);
    imshow("matches", img_matches);
    waitKey(0);

    return 0;
}

During compilation, I got this:

error: 'SURF' has not been declared Ptr<feature2d> surf1 = SURF::create();

error: 'BruteForceMatcher' was not declared in this scope BruteForceMatcher<l2<float> > matcher;

error: expected primary-expression before '>' token BruteForceMatcher<l2<float> > matcher;

error: 'matcher' was not declared in this scope BruteForceMatcher<l2<float> > matcher;

On searching, I found that #include "opencv2/nonfree/features2d.hpp" should be added. However, I don't have any folder nonfree or misc in the opencv2 folder. I am using opencv 3.0.0. And, have compiled it using mingw.

Can anyone help in telling as if why this error is appearing. And, how can I resolve it.

I have looked at http://answers.opencv.org/question/52...

but don't understand that on donloading zip file, where shall I place it. How shall it be compiled to add to the existing build of opencv.

@berak , can you help me wih this ?

2015-05-20 06:38:07 -0600 commented question undefined reference to `cv::fastFree(void*)' & 'cv::Mat::deallocate()'

I made wrong entry for path. it's working now.

Thanks a lot!! :)

2015-05-20 06:36:03 -0600 commented question undefined reference to `cv::fastFree(void*)' & 'cv::Mat::deallocate()'

I have tried using absolute path but still it is taking the image as an empty matrix. I have tried for .jpg image as well. But, that too is not appearing.

2015-05-20 06:10:06 -0600 commented question undefined reference to `cv::fastFree(void*)' & 'cv::Mat::deallocate()'

Thanks @berak. I had not added imgcodecs. The code compiles successfully. But, on execution, the program stops working giving error: "Assertion failed (size.width>0 && size.height>0) in imshow, file C:\opencv\opencv-master\opencv-master\modules\highgui\src\window.cpp, line 271"

2015-05-20 05:17:23 -0600 commented question undefined reference to `cv::fastFree(void*)' & 'cv::Mat::deallocate()'

@berak , Now, I have compiled the opencv library using CMake. And, I am using C++ API.

The simple code for checking if the library has been set up fine is :

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv/cv.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
using namespace cv;
int main()
{
    cv::Mat image = cv::imread("error.png", 0);// read the file
    cv::namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// create a window for display.
    cv::imshow( "Display window", image );// show our image inside it.
    cv::waitKey(0);// wait for a keystroke in the window
    return 0;
}

But, this is still giving an undefined reference error for `cv::imread(cv::String const&, int)' Can you tell me what can be wrong?

2015-05-19 03:51:08 -0600 asked a question undefined reference to `cv::fastFree(void*)' & 'cv::Mat::deallocate()'

I am doing template matching on eclipse CDT using C++ API.

The code is :

#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/mat.hpp"
#include "opencv/cv.hpp"
using namespace cv;

#include <iostream>
#include <stdio.h>
using namespace std;


/// Global Variables
IplImage* img;
IplImage* templ;
IplImage* result;
char* image_window = "Source Image";
char* result_window = "Result window";

int match_method;
int max_Trackbar = 5;

int main( int argc, char** argv )
{
    img = cvLoadImage("C:\\Users\\..\\workspace\\OpenCV_CPP\\src\\myimg.png",true);
    templ = cvLoadImage("C:\\Users\\...\\workspace\\OpenCV_CPP\\src\\mytmp.png",true);

    /// Create windows
    cvNamedWindow( image_window, CV_WINDOW_AUTOSIZE );
    cvNamedWindow(result_window, CV_WINDOW_AUTOSIZE );
    Mat img_display;
    CvArr* msk2;
    cvCopy(&img,&img_display,&msk2);
      /// Create the result matrix
      int result_cols =  img->width - templ->width + 1;
      int result_rows = img->height - templ->height + 1;
      CvSize cs = cvSize(result_cols,result_rows);
      cvCreateImage(cs,CV_32FC1,3);
      match_method = 0;
      /// Do the Matching and Normalize
      cvMatchTemplate(&img,&templ,&result,match_method);
      CvArr* msk1;
      cvNormalize(&result,&result,0,1,NORM_MINMAX,&msk1);
      double minVal; double maxVal; CvPoint minLoc; CvPoint maxLoc;
      Point matchLoc;
      CvArr* msk;
      cvMinMaxLoc( &result, &minVal, &maxVal, &minLoc, &maxLoc, &msk);
      matchLoc = minLoc;
      if( match_method  == 0 || match_method == 1 )
        { matchLoc = minLoc; }
      else
        { matchLoc = maxLoc; }
      cvRectangle( &img_display, matchLoc, Point( matchLoc.x + templ->height , matchLoc.y + templ->height ), Scalar::all(0), 2, 8, 0 );
      cvRectangle( &result, matchLoc, Point( matchLoc.x + templ->width , matchLoc.y + templ->height ), Scalar::all(0), 2, 8, 0 );
      cvShowImage(image_window, &img_display);
      cvShowImage(result_window, &result);
      cvWaitKey(0);
      cvReleaseImage(&img );
      cvReleaseImage(&templ );
      cvReleaseImage(&result );
    return 0;
}

On compilation, I get 2 errors :-

C:/OpenCV-3.0/opencv/build/include/opencv2/core/mat.hpp:278: undefined reference to cv::fastFree(void*)' src\DisplayImage.o: In functionZN2cv3Mat7releaseEv': C:/OpenCV-3.0/opencv/build/include/opencv2/core/mat.hpp:367: undefined reference to `cv::Mat::deallocate()'

Please suggest on how to deal with them.

2015-05-18 00:48:28 -0600 asked a question Assertion failed in template matching

I am trying to perform template matching in C. The code compiles fine. But, during execution, it gives the error : "OpenCV Error: Assertion failed (result.size() == cv::Size(std::abs(img.cols - templ.cols) + 1, std::abs(img.rows - templ.rows) + 1) && result.type() == CV_32F) in cvMatchTemplate, file ........\opencv\modules\imgproc\src\templmatch.cpp, line 386"

The code is :

#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
int main(int argc, char *argv[])
{
    IplImage* templ = 0;
    IplImage* img = 0;
    int height_i,width_i;
    int channels_i,height_t,width_t;
    int channels_t;
    printf("Taking images as input.....");


    img = cvLoadImage("C:\\Users\\....\\workspace\\TemplateMatchingInC\\src\\image.jpg",CV_LOAD_IMAGE_COLOR);
    templ = cvLoadImage("C:\\Users\\...\\workspace\\TemplateMatchingInC\\src\\template.jpg",CV_LOAD_IMAGE_COLOR);

    if(!img)
    {  printf("Could not load image file \n");  exit(0);  }
    if(!templ)
    {  printf("Could not load template file \n");  exit(0);  }

    printf("Finding image components....");

    // get the image data
    height_i    = img->height;
    width_i     = img->width;
    channels_i  = img->nChannels;
    printf("Processing a %dx%d image with %d channels\n",height_i,width_i,channels_i);

    // get the template data
    height_t    = templ->height;
    width_t     = templ->width;
    channels_t  = templ->nChannels;
    printf("Processing a %dx%d template with %d channels\n",height_t,width_t,channels_t);

    CvRect roiFace = cvRect(0, 0,width_t,height_t);
    cvSetImageROI(img, roiFace);
    CvSize size_res = cvSize((width_i - width_t + 1),(height_i - height_t + 1));

    IplImage* res = cvCreateImage(size_res,IPL_DEPTH_32F, channels_i);

    printf("res height : %d  ",res->height);
    printf("res width : %d  ",res->width);
    printf("res depth : %d  ",res->depth);

    CvPoint *minloc= NULL;

    // do template matching
    cvMatchTemplate(img,templ,res,CV_TM_SQDIFF);

    // highlighting template over image
    minloc->x = 0;
    minloc->y = 0;

    CvPoint p1,p2;
    p1.x = minloc->x;
    p1.y = minloc->y;
    p2.x = minloc->x + width_t;
    p2.y = minloc->y + height_t;

    cvMinMaxLoc(res,NULL,NULL,minloc,NULL,NULL);
    cvRectangle(img,p1,p2,cvScalar(0,0,255,0),1,0,0);

    // create a window
    cvNamedWindow("Template_Matching", CV_WINDOW_AUTOSIZE);
    cvMoveWindow("Template_Matching", 100, 100);

    // show the image
    cvShowImage("Template_Matching", img );

    // wait for a key
    cvWaitKey(0);

    // release the image
    cvReleaseImage(&res );



    cvReleaseImage(&img );
    cvReleaseImage(&templ );
    return 0;
}