Skip to content

Instantly share code, notes, and snippets.

@yoggy
Created November 9, 2010 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoggy/669359 to your computer and use it in GitHub Desktop.
Save yoggy/669359 to your computer and use it in GitHub Desktop.
//
// $ gcc -I/usr/local/opencv2.1/include/ -std=c99 -L/usr/local/opencv2.1/lib -lhighgui -lcv -lcxcore -o cvmattest cvmattest.c
// $ DYLD_LIBRARY_PATH=/usr/local/opencv2.1/lib ./cvmattest
//
#include <stdio.h>
#include <stdlib.h>
#include <opencv/cv.h>
#include <opencv/cxcore.h>
int
main(int argc, char *argv[])
{
CvMat *mat, *src, *dst;
mat = cvCreateMat(3, 3, CV_32FC1);
src = cvCreateMat(3, 1, CV_32FC1);
dst = cvCreateMat(3, 1, CV_32FC1);
cvmSet(mat, 0, 0, 1);
cvmSet(mat, 0, 1, 0);
cvmSet(mat, 0, 2, 1);
cvmSet(mat, 1, 0, 0);
cvmSet(mat, 1, 1, 1);
cvmSet(mat, 1, 2, 0);
cvmSet(mat, 2, 0, 0);
cvmSet(mat, 2, 1, 0);
cvmSet(mat, 2, 2, 1);
cvmSet(src, 0, 0, 1);
cvmSet(src, 1, 0, 1);
cvmSet(src, 2, 0, 1);
cvmMul(mat, src, dst);
printf("dst=(%f, %f, %f)\n",
dst->data.fl[0],
dst->data.fl[1],
dst->data.fl[2]
);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment