OpenCV on Zynq

OpenCVの環境もYoctoで組み込めたので、さっそく、サンプルコードを書いて試してみた。

OpenCVのページに書いている次のサンプルコードをコンパイルして、実行!

ソースコード#include <cv.h>

include <highgui.h>

include <math.h>

int

main (int argc, char **argv)

{

  int angle = 45;

  float m[6];

  IplImage src_img = 0, dst_img = 0;

  CvMat M;

  if (argc >= 2)

    src_img = cvLoadImage (argv[1], CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR),

  if (src_img == 0)

    return -1;

  dst_img = cvCloneImage (src_img),

  m[0] = (float) (cos (angle * CV_PI / 180.)),

  m[1] = (float) (-sin (angle * CV_PI / 180.)),

  m[2] = src_img->width * 0.5;

  m[3] = -m[1];

  m[4] = m[0];

  m[5] = src_img->height * 0.5;

  cvInitMatHeader (&M, 2, 3, CV_32FC1, m, CV_AUTOSTEP),

  cvGetQuadrangleSubPix (src_img, dst_img, &M),

  cvNamedWindow ("src", CV_WINDOW_AUTOSIZE),

  cvNamedWindow ("dst", CV_WINDOW_AUTOSIZE),

  cvShowImage ("src", src_img),

  cvShowImage ("dst", dst_img),

  cvWaitKey (0),

  cvReleaseImage (&src_img),

  cvReleaseImage (&dst_img),

  return 1;

}

コンパイル% g++ -I/usr/include/opencv -lopencv_highgui -lopencv_imgproc -lopencv_core -o sample sample.c

実行結果% ./sample ./sample.jpg

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /mnt/disk1/yocto/yocto_2014.12_2/poky/build/tmp/work/armv7a-vfp-neon-poky-linux-gnueabi/opencv/2.4.9+gitAUTOINC+df8e28283f-r0/git/modules/highgui/src/window.cpp, line 483

terminate called after throwing an instance of ''cv::Exception''

  what():  /mnt/disk1/yocto/yocto_2014.12_2/poky/build/tmp/work/armv7a-vfp-neon-poky-linux-gnueabi/opencv/2.4.9+gitAUTOINC+df8e28283f-r0/git/modules/highgui/src/window.cpp:483: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow

Aborted

まとめDirectFBでは、ダメかなと思ってたけど、その前にHighGUIはGTK+だったことをすっかり忘れていた。

GTK+をDirectFB対応で構築できていれば問題なく使用できるということか?

まぁ、それか、画像処理だけOpenCVで実行して、映像出力はDirectFBで組んでしまうというのも手かな。

write: 2015/01/04/ 00:52:16