Starting with OpenCV for IMX6 processor

i am going through Starting with OpenCV on i.MX6 processors
I am following whatever has done in this. now i need to cross compile the following code

mkdir src
gedit src/myApp.cpp

#include 
#include 

using namespace std;
using namespace cv;

int main(int argc, char** argv ){
cout << "OpenCV version: " << CV_MAJOR_VERSION << '.' << CV_MINOR_VERSION << "\n";
if ( argc != 2 ){
    cout << "usage: ./myApp \n";
    return -1;
}

Mat image;
image = imread( argv[1], 1 );

if ( !image.data ){
    cout << "No image data \n";
    return -1;
}

bitwise_not(image, image);
namedWindow(“Display Image”, WINDOW_AUTOSIZE );
imshow(“Display Image”, image);

waitKey(0);

return 0;

}
i have run this code. An error has occured in line 1 and 2
What should i do?

What errors did you get?

There is an error on the blog, the first two lines are not correctly shown on the website. We will correct this. Meanwhile try to change the first two lines to the following and try the compilation again:

#include <iostream>
#include <cstdlib>

You also need to add the other include files, which are described on the website you mentioned.

Best regards,
Jaski

Please solve this

bmit@bmit-HP:~/my_project/src$ gcc -o myApp myApp.cpp
myApp.cpp:5:17: error: ‘cv’ is not a namespace-name
 using namespace cv;
                 ^
myApp.cpp:5:19: error: expected namespace-name before ‘;’ token
 using namespace cv;
                   ^
myApp.cpp: In function ‘int main(int, char**)’:
myApp.cpp:8:31: error: ‘CV_MAJOR_VERSION’ was not declared in this scope
 cout << "OpenCV version: " << CV_MAJOR_VERSION << '.' << CV_MINOR_VERSION << "\n";
                               ^
myApp.cpp:8:58: error: ‘CV_MINOR_VERSION’ was not declared in this scope
 cout << "OpenCV version: " << CV_MAJOR_VERSION << '.' << CV_MINOR_VERSION << "\n";
                                                          ^
myApp.cpp:15:5: error: ‘Mat’ was not declared in this scope
     Mat image;
     ^
myApp.cpp:15:9: error: expected ‘;’ before ‘image’
     Mat image;
         ^
myApp.cpp:16:5: error: ‘image’ was not declared in this scope
     image = imread( argv[1], 1 );
     ^
myApp.cpp:16:32: error: ‘imread’ was not declared in this scope
     image = imread( argv[1], 1 );
                                ^
myApp.cpp:22:25: error: ‘bitwise_not’ was not declared in this scope
 bitwise_not(image, image);
                         ^
myApp.cpp:23:34: error: ‘WINDOW_AUTOSIZE’ was not declared in this scope
     namedWindow("Display Image", WINDOW_AUTOSIZE );
                                  ^
myApp.cpp:23:50: error: ‘namedWindow’ was not declared in this scope
     namedWindow("Display Image", WINDOW_AUTOSIZE );
                                                  ^
myApp.cpp:24:34: error: ‘imshow’ was not declared in this scope
     imshow("Display Image", image);
                                  ^
myApp.cpp:26:14: error: ‘waitKey’ was not declared in this scope
     waitKey(0);
              ^
bmit@bmit-HP:~/my_project/src$ gcc -o myApp myApp.cpp
myApp.cpp: In function ‘int main(int, char**)’:
myApp.cpp:17:32: error: ‘imread’ was not declared in this scope
     image = imread( argv[1], 1 );
                                ^
myApp.cpp:24:34: error: ‘WINDOW_AUTOSIZE’ was not declared in this scope
     namedWindow("Display Image", WINDOW_AUTOSIZE );
                                  ^
myApp.cpp:24:50: error: ‘namedWindow’ was not declared in this scope
     namedWindow("Display Image", WINDOW_AUTOSIZE );
                                                  ^
myApp.cpp:25:34: error: ‘imshow’ was not declared in this scope
     imshow("Display Image", image);
                                  ^
myApp.cpp:27:14: error: ‘waitKey’ was not declared in this scope
     waitKey(0);
              ^
bmit@bmit-HP:~/my_project/src$ gcc -o myApp myApp.cpp
myApp.cpp: In function ‘int main(int, char**)’:
myApp.cpp:17:32: error: ‘imread’ was not declared in this scope
     image = imread( argv[1], 1 );
                                ^
myApp.cpp:24:34: error: ‘WINDOW_AUTOSIZE’ was not declared in this scope
     namedWindow("Display Image", WINDOW_AUTOSIZE );
                                  ^
myApp.cpp:24:50: error: ‘namedWindow’ was not declared in this scope
     namedWindow("Display Image", WINDOW_AUTOSIZE );
                                                  ^
myApp.cpp:25:34: error: ‘imshow’ was not declared in this scope
     imshow("Display Image", image);
                                  ^
myApp.cpp:27:14: error: ‘waitKey’ was not declared in this scope
     waitKey(0);
              ^
bmit@bmit-HP:~/my_project/src$

I guess you need to add:

#include <stdio.h>
#include <opencv2/opencv.hpp>

i have edited the headers and the above errors have occured. Please give a clear explanation of the code and errors

Did you follow the Blog correctly? You should use the command make to compile as it is described in the blog.

ok. Thank you

You are welcome.