Computer Vision & AI/OpenCV

YOLO C++ detect 에러 (C2664)

_heyna 2022. 11. 9. 13:50

- 환경 & 증상

yolo_v2_class.hpp

yolo detect함수에서 에러가 발생

 

- 원인 파악 과정

인자가 다르다는 에러가 나옴.

detect함수에서 F12눌러서 코드 들어가보니

  LIB_API std::vector<bbox_t> detect(std::string image_filename, float thresh = 0.2, bool use_mean = false);
  LIB_API std::vector<bbox_t> detect(image_t img, float thresh = 0.2, bool use_mean = false);

이렇게만 나오는데... 코드 짜신 분은 인자로 Mat을 넣어놨다. 그래서 안되나 싶었는데 그분은 잘 되셨음...

왜 나만 안되는걸까?!

 

- 해결방법

#ifdef OPENCV
    std::vector<bbox_t> detect(cv::Mat mat, float thresh = 0.2, bool use_mean = false)
    {
        if(mat.data == NULL)
            throw std::runtime_error("Image is empty");
        auto image_ptr = mat_to_image_resize(mat);
        return detect_resized(*image_ptr, mat.cols, mat.rows, thresh, use_mean);
    }

이 함수를 탔어야 했는데 OPENCV가 비활성 상태였음.ㅎ

전처리기에 OPENCV추가해 주고 해결 완료!