Opencv4 undefined types

asked 2019-08-07 09:59:58 -0600

h438 gravatar image

updated 2019-08-07 10:06:20 -0600

berak gravatar image

After installing opencv4 dynamically using cmake:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/Libs/opencv/dynamic ..

I tried to test on a simple example

#include <opencv4/opencv2/core.hpp>
#include <opencv4/opencv2/highgui.hpp>
#include <opencv4/opencv2/imgcodecs.hpp>
#include <opencv4/opencv2/imgproc.hpp>

int main(int argc, char **argv) {
  if (argc != 2) {
    std::cout << "usage: DisplayImage.out <Image_Path>\n" << std::endl;
    return -1;
  }

  cv::Mat image = cv::imread(std::string{argv[1]});
  if (!image.data) {
      printf("No image data \n");
      return -1;
  }

  cv::rectangle(image, cv::Point(0, 0), cv::Point(112, 112),
                cv::Scalar(0, 255, 0), 10, cv::LINE_4);
  cv::putText(image, "Opencv", cv::Point(0, 112),
              cv::FONT_HERSHEY_COMPLEX_SMALL, 0.8, cv::Scalar(255, 0, 225));
  cv::imshow("Opencv 4", image);
  cv::waitKey(0);
  return 0;
}

I get the following errors

error : use of undeclared identifier 'image'
error : no member named 'Point' in namespace 'cv'
error : calling 'waitKey' with incomplete return type 'cv::CV_EXPORTS_W'

Basically there are forward declarations of the types but they do not seem to be defined anywhere

edit retag flag offensive close merge delete

Comments

please use headers like: #include <opencv2/core.hpp> (and adjust the compiler's include path)

berak gravatar imageberak ( 2019-08-07 10:08:37 -0600 )edit