Java Program to Copy and Paste an image in OpenCV
OpenCV is a Machine Learning and open-source computer vision software library, the main purpose for which it was developed is to enable a common medium to increase the use of machine perception in commercial businesses and accelerate the development of computer vision applications, it is a smooth and easy transition for businesses to adopt and use OpenCV as it has the advantage of being BSD-licensed product.
- The library of OpenCV has 2000+ algorithms that are efficiently optimized and which also contains state-of-art computer vision and classical Machine Learning Algorithms.
- These Algorithms were mainly used for performing various tasks like recognizing faces, identification of objects, classification of human activities in videos, extraction of 3D models of objects, extraction of higher resolution in images, finding similar images from a picture database… etc.
- OpenCV also contains various language interfaces such as Java, Python, C++, MATLAB and it extensively supports Linux, Android, Windows, macOS. In other words, it supports almost all popular existing Operating Systems thus enabling a large Audience in its user’s list.
Input Image: Sample image present at the local directory in the system at the local directory. Here the directory from which the image is extracted to interpret as the multidimensional array is shown below:
Local directory from where below sample image is copied: “C:/opencv/gfgarticleimg.png”
Now, as we got to know what is OpenCV, let us try to build a java program that enables us in copying and pasting an image with OpenCV.
- Import OpenCV modules and load core libraries.
- Read the image from the local directory and store it in the Matrix object.
- Interpret image as a multi-dimensional matrix.
- Store this multi-dimensional structure writing to some different local directory as specified from where it is extracted to be. copied.
String f =
Mat m = Imgcodecs.imread(f);
"Your Image has been Loaded......."
String f2 =
"congrats! your image has been saved........"
Local directory to where above sample shown below is pasted: “C:/opencv/gfgarticleimgResaved.png”
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!