AnsweredAssumed Answered

Using OpenCV with Yocto on the iMX6

Question asked by Juan Rosell on Aug 12, 2015
Latest reply on Aug 12, 2015 by Wigros Sun

Hi,

 

I think there was a similar question already asked in which it was asked how to install OpenCV in a Yocto image. After doing that successfully, I tried to cross compile a small application reading frames from a camera. The code follows here:

#include <stdlib.h>

#include <stdio.h>

#include <math.h>

#include <opencv2/core/core.hpp>

#include <opencv2/highgui/highgui.hpp>

#include <opencv2/imgproc/imgproc.hpp>

 

int main(int argc, char *argv[]){

if (argc < 2){

  printf("Usage: cameratest cameraId \n");

  return 0;

}

printf("Trying camera at port %s \n", argv[1]);

cv::VideoCapture capture = cv::VideoCapture(atoi(argv[1]));

if (capture.isOpened() == false){

  printf("Could not open camera port. \n");

  return -1;

}

cv::Mat frame;

int frameCount = 0;

printf("Camera test started. \n");

while(1){

  if (! capture.read(frame) ){

   printf("Failed reading. \n");

   break;

  }

  printf("Read frame %d \n", frameCount);

}

}

 

and the CMakeLists.txt file that I'm using here:

 

cmake_minimum_required(VERSION 2.6)

project(camera_test)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -O3 -fsigned-char -march=armv7-a -mfpu=neon -mfloat-abi=hard")

file(GLOB_RECURSE src/*.cpp)

find_package(OpenCV REQUIRED)

add_executable(camera_test src/camera_test.cpp)

target_link_libraries(camera_test opencv_core opencv_ml opencv_highgui)

install(TARGETS camera_test DESTINATION /usr/bin)

~                                                 

 

I can create the image with this code and there is no problem, but when I try to execute it, I always get the same error:

 

~# camera_test 0

Trying camera at port 0

Floating point exception

 

There is no other error message and the code runs in my machine (native compilation) without any problem.  Did someone experience this problem before? I had to patch the kernel in order to change the camera driver from mt9p032 to the mt9v032 (Phytec cameras) but I don't think this should have anything to do with it.... However, in the dmesg output I found this line:

 

coda 2040000.vpu: Direct firmware load for v4l-coda960-imx6q.bin failed with error -2

 

Could it be the problem? In that case, how can it be solved?

 

Best regards,

 

Juan

Outcomes