opencv c++ hello world

  1. Include the necessary header files at the beginning of the program:
#include <opencv2/opencv.hpp>
  1. Create the main function:
int main() {
  1. 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);
  1. Display the image in a window:
    cv::imshow("Hello, OpenCV!", image);
  1. Wait for a key press and then close the window:
    cv::waitKey(0);
    return 0;
}