Question

I am using OpenCV on an embedded target board (FriendlyARM mini6410, processor arm 1176 running linux kernel 2.6.38). I compiled OpenCV 2.4.4 library using toolchain provided for the board, found in the ftp (pls see the website of FriendlyARM). I disabled GTK, ffmpeg and enable v4l. The library is compiled successfully.

Then I write code:

#include <opencv.hpp>
#include <highgui/highgui.hpp>
#include <imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>

using namespace cv;
using namespace std;

int main()
{
    int i;
    cout << "initialise" << endl;
    IplImage* img=0;
    cout << "capturing ..." << endl;
    CvCapture* capture = cvCaptureFromCAM(2);
    cout << "get here" << endl;
    if(!capture){
        cout << "not capture" << endl;
        return -1;
    }
    cout << "captured" << endl;
    img=cvQueryFrame(capture);

   IplImage* img1 = cvCreateImage(cvGetSize(img),8,3);
   // cvCvtColor(img,img1,CV_RGB2GRAY);
   cvCopy(img, img1);
   cvSaveImage("cam_snap.jpg",img1);
   cvReleaseImage( &img1 );
   cvReleaseImage( &img );
   cvReleaseCapture( &capture );
   cout << "exit" << endl;

   return 0;
}

The code is built successfully. I run the .elf executable in the target board, connected to camera (PS3 eye), but the resulting image looks like a broken television (noise-like):

noise like image

While in my host, the resulting image is as expected (scene in front of camera). Can you provide me suggestion as to what went wrong or where should I start on debugging?

Was it helpful?

Solution 2

Okay, confirmed. mini 6410 runs USB 1.0, and ps3 eye needs USB 2.0. I tried the program using standard webcam (chinese product, itech pc camera), works wonderfully. Saved image is showing scene in front of camera

OTHER TIPS

You should check your depth and channels. It is probably a matter of alignement, moreover be careful your image is probably in BGR and not in RGB. And you should use cv::Mat instead of IplImage in C++ and VideoCapture instead of CVCapture.

This sample of code should work. (Not tested on the same arch as your)

#include <opencv.hpp>
#include <highgui/highgui.hpp>
#include <imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>

using namespace cv;
using namespace std;

int main()
{
    VideoCapture capture = cv::VideoCapture(0);
    cout << "get here" << endl;
    if(!capture.isOpened())  // check if we succeeded                                                                                                   
         return -1;

    cout << "captured" << endl;
    Mat img;
    capture >> img;
    imwrite("./test.png", img);
    capture.release();
    cout << "exit" << endl;
    return 0;
}

Hope it helped.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top