opencv c++ hello world
- Include the necessary header files at the beginning of the program:
#include <opencv2/opencv.hpp>
- Create the main function:
int main() {
- Display a "Hello, World!" message using OpenCV:
cv::Mat image = cv::Mat::zeros(480, 640, CV_8UC3);
cv::putText(image, "Hello, World!", cv::Point(100, 240), cv::FONT_HERSHEY_SIMPLEX, 1.0, cv::Scalar(0, 255, 255), 2);
- Display the image in a window:
cv::imshow("Hello, OpenCV!", image);
- Wait for a key press and then close the window:
cv::waitKey(0);
return 0;
}