Download samples/cpp/tutorial_code/introduction/display_image/display_image.cpp from tgollogly/test: direct link, hf CLI and curl.
- Browser
- Download file 744 Bytes
-
https://huggingface.co/tgollogly/test/resolve/main/samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
- Command line
-
hf download hf://tgollogly/test/samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
-
curl -L -o display_image.cpp https://huggingface.co/tgollogly/test/resolve/main/samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
744 Bytes
| //! [includes] | |
| using namespace cv; | |
| //! [includes] | |
| int main() | |
| { | |
| //! [imread] | |
| std::string image_path = samples::findFile("starry_night.jpg"); | |
| Mat img = imread(image_path, IMREAD_COLOR); | |
| //! [imread] | |
| //! [empty] | |
| if(img.empty()) | |
| { | |
| std::cout << "Could not read the image: " << image_path << std::endl; | |
| return 1; | |
| } | |
| //! [empty] | |
| //! [imshow] | |
| imshow("Display window", img); | |
| int k = waitKey(0); // Wait for a keystroke in the window | |
| //! [imshow] | |
| //! [imsave] | |
| if(k == 's') | |
| { | |
| imwrite("starry_night.png", img); | |
| } | |
| //! [imsave] | |
| return 0; | |
| } | |