Ask Your Question
0

error C3861: 'cv2DRotationMatrix': identifier not found / error C3861: 'cvWarpAffine': identifier not found

asked 2014-02-06 03:21:59 -0500

Vaaaaaaaaaaaaaaaaaaaa gravatar image

updated 2014-02-06 05:03:04 -0500

berak gravatar image

Someone please help me solve this problem thanks

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

using namespace cv;
using namespace std;


IplImage *rotateImage(const IplImage *src, int angleDegrees, double zoom)
{    
    IplImage *imageRotated = cvCloneImage(src);


    CvMat* rot_mat = cvCreateMat(2,3,CV_32FC1);

    // Compute rotation matrix
    CvPoint2D32f center = cvPoint2D32f( cvGetSize(imageRotated).width/2, cvGetSize(imageRotated).height/2 );
    cv2DRotationMatrix( center, angleDegrees, zoom, rot_mat );

    // Do the transformation
    cvWarpAffine( src, imageRotated, rot_mat );

    return imageRotated;
}


int main()
{

          IplImage* img;
          IplImage* rotated_img;

          int angle=0;
          int zoom=24;

          //creating the window with 2 track bars
          cvNamedWindow("MyWindow");
          cvCreateTrackbar("Angle", "MyWindow", &angle, 360, 0);
          cvCreateTrackbar("Zoom", "MyWindow", &zoom, 99, 0);

          while(true){
              //load the original image
              img = cvLoadImage("C:/MyPic.jpg");

              //rotate the image
              rotated_img=rotateImage( img, angle, (zoom+1)/25.0 );

              //display the rotated image
              cvShowImage("MyWindow", rotated_img); 

              //clean up
              cvReleaseImage(&img);
              cvReleaseImage(&rotated_img);

              //if user press 'ESC' button, program quit the while loop
              int c=cvWaitKey(50);               
              if(c==27) break;
          }


          cvDestroyWindow("MyWindow");

          return 0;
}
edit retag flag offensive close merge delete

Comments

You should not use the old C-API if possible. Berak, wrote this already in your previous post http://answers.opencv.org/question/27816/fatal-error-c1083-cannot-open-include-file/

Siegfried gravatar imageSiegfried ( 2014-02-06 04:18:28 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-02-06 05:01:26 -0500

berak gravatar image

hmm, please try to avoid the old c-api, use the newer c++ one whenever possible:


#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/core/core.hpp"
using namespace cv;

int angle=180;
Mat im;
Mat dst_image;
void onChange(int,void*)
{
    Point2f cen(dst_image.cols/2,dst_image.rows/2);
    double scale = 1.0;
    double a = double(angle-180);
    Mat rot_mat = getRotationMatrix2D(cen, a, scale);
    warpAffine(im, dst_image, rot_mat, Size(), INTER_LINEAR); 
    imshow("lala",dst_image);
}
int main()
{
    im = imread("E:/MEDIA/faces/grimace/pat/pat_exp.17.jpg", 1);
    dst_image = Mat(im.rows*1.5,im.cols*1.5,im.type(),Scalar::all(0));
    namedWindow("lala", 0);
    createTrackbar("a","lala",&angle,360,onChange);
    onChange(0,0);
    waitKey();
    return 0;
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-02-06 03:21:59 -0500

Seen: 917 times

Last updated: Feb 06 '14