Using OpenCV with Yocto on the iMX6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using OpenCV with Yocto on the iMX6

1,753 Views
juanrosell
Contributor I

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

Labels (2)
0 Kudos
1 Reply

595 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi Juan,

     Our VPU firmware's name is vpu_fw_imx6q.bin , not v4l-coda960-imx6q.bin, so please check the reason why the message displayed.

Regards.

Weidong

0 Kudos