OpenCV: How to use cvSobel? -


i'm trying find gradient direction edges using opencv 2.4.5, i'm having problem cvsobel() , below error message , code. read somewhere might due conversion between floating point(??) have no idea on how fix it. help??

enter image description here

#include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2\opencv.hpp> #include <opencv2\calib3d\calib3d.hpp>  #include <iostream> #include <stdlib.h> #include "stdio.h"  using namespace cv; using namespace std;  int main() {     mat im = imread("test1.jpg");     if (im.empty()) {         cout << "cannot load image!" << endl;     }     mat *dx, *dy;     dx = new mat( mat::zeros(im.rows, im.cols, 1));      dy = new mat( mat::zeros(im.rows, im.cols, 1));      imshow("image", im);      // convert image gray scale     mat im_gray;     cvtcolor(im, im_gray, cv_rgb2gray);     imshow("gray", im_gray);              //trying find direction, gives errors here     cvsobel(&im_gray, dx, 1,0,3);       waitkey(0);     return 0; } 

you mixing c++ , c api. cv::mat c++ api , cvarr* c api. here using c api cvsobel on c++ classes.

//trying find direction, gives errors here cvsobel(&im_gray, dx, 1,0,3); 

what happens if do

cv::sobel( im_gray, dx, im_gray.depth(), 1, 0, 3); 

edit , declare

mat dx; mat dy; 

i think might solve problem, i'm quite surprised code compiles.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -