1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2020-04-08 10:19:09 +00:00
23 changed files with 628 additions and 541 deletions
@@ -4,48 +4,36 @@
#include <opencv2/highgui.hpp>
#include <iostream>
using namespace cv;
//! [includes]
//! [namespace]
using namespace cv;
using namespace std;
//! [namespace]
int main( int argc, char** argv )
int main()
{
//! [load]
String imageName( "HappyFish.jpg" ); // by default
if( argc > 1)
{
imageName = argv[1];
}
//! [load]
//! [mat]
Mat image;
//! [mat]
//! [imread]
image = imread( samples::findFile( imageName ), IMREAD_COLOR ); // Read the file
std::string image_path = samples::findFile("starry_night.jpg");
Mat img = imread(image_path, IMREAD_COLOR);
//! [imread]
if( image.empty() ) // Check for invalid input
//! [empty]
if(img.empty())
{
cout << "Could not open or find the image" << std::endl ;
return -1;
std::cout << "Could not read the image: " << image_path << std::endl;
return 1;
}
//! [window]
namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
//! [window]
//! [empty]
//! [imshow]
imshow( "Display window", image ); // Show our image inside it.
imshow("Display window", img);
int k = waitKey(0); // Wait for a keystroke in the window
//! [imshow]
//! [wait]
waitKey(0); // Wait for a keystroke in the window
//! [wait]
//! [imsave]
if(k == 's')
{
imwrite("starry_night.png", img);
}
//! [imsave]
return 0;
}
@@ -0,0 +1,19 @@
## [imports]
import cv2 as cv
import sys
## [imports]
## [imread]
img = cv.imread(cv.samples.findFile("starry_night.jpg"))
## [imread]
## [empty]
if img is None:
sys.exit("Could not read the image.")
## [empty]
## [imshow]
cv.imshow("Display window", img)
k = cv.waitKey(0)
## [imshow]
## [imsave]
if k == ord("s"):
cv.imwrite("starry_night.png", img)
## [imsave]