Ask Your Question

Revision history [back]

Translating code from C++


I'm trying to learn OpenCV in JAVA, but I have really bad time searching for any source of information. I want to load and display an image using OpenCV exacly like in this tutorial below, but using JAVA:

int main( int argc, char** argv ) {
String imageName( "../data/HappyFish.jpg" ); // by default
if( argc > 1)
    imageName = argv[1];
Mat image;
image = imread( imageName, IMREAD_COLOR ); // Read the file
if( image.empty() )                      // Check for invalid input
    cout <<  "Could not open or find the image" << std::endl ;
    return -1;
namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
imshow( "Display window", image );                // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0; }

If you know any tutorials for OpenCV using JAVA I would be grateful if you could link them.