I tried many things which I saw as solutions. But nothing worked here.
My configuration:
I'm getting this error:
In file included from /usr/local/include/dlib/opencv.h:10,
from /home/zeobora/openCv/c++/facial_recognition/trainModel/trainModel.cpp:3:
/usr/local/include/dlib/opencv/cv_image.h:
In instantiation of ‘dlib::cv_image<pixel_type>::cv_image(cv::Mat)
[with pixel_type = dlib::bgr_pixel]’:
/home/zeobora/openCv/c++/facial_recognition/trainModel/trainModel.cpp:45:75:
required from here /usr/local/include/dlib/opencv/cv_image.h:37:29:
error: conversion from ‘const cv::Mat’ to non-scalar type
‘IplImage’ {aka ‘_IplImage’} requested 37 | IplImage temp = img; ^~~
make[2]: *** [CMakeFiles/trainModel.dir
/build.make:63: CMakeFiles/trainModel.dir/trainModel.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/trainModel.dir/all]
Error 2 make: *** [Makefile:130: all] Error 2
Here is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.15)
set(CMAKE_CXX_STANDARD 17)
project( trainModel )
find_package( OpenCV REQUIRED )
include_directories( "/usr/local/include/opencv4/opencv2" )
find_package(dlib REQUIRED)
include_directories("/usr/local/include")
add_executable( trainModel trainModel.cpp )
target_link_libraries( trainModel ${OpenCV_LIBS} dlib::dlib )
install( TARGETS trainModel DESTINATION bin)
Here is my code piece which is this error coming from.
#include <iostream>
#include <opencv2/opencv.hpp>
#include <dlib/opencv.h>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_processing/render_face_detections.h>
#include <dlib/image_processing.h>
#include <dlib/gui_widgets.h>
#include <dlib/image_io.h>
int main(){
//Some codes here which isn't related...
dlib::frontal_face_detector detector = dlib::get_frontal_face_detector();
dlib::shape_predictor pose_model;
dlib::deserialize("/home/openCv/models/shape_predictor_68_face_landmarks.dat") >> pose_model;
cv::Mat image, grayImage;
for (int i = 0; i < personNumber; i++){
image = cv::imread( pictures[i] );
//My problem begins here.
dlib::array2d<dlib::bgr_pixel> newImage;
dlib::assign_image(newImage, dlib::cv_image<dlib::bgr_pixel>(image));
//My problem ends here.
std::vector<dlib::rectangle> dets = detector(newImage);
std::cout << "Number of faces detected: " << dets.size() << std::endl;
while(1){
cv::imshow("Image", image);
char key=(cv::waitKey(1)&(0xFF));
if (key=='q'){
break;
}
}
}
cv::destroyAllWindows();
return 0;
}
Can you please help me to convert it so I can use it with dlib library.
I uninstalled the old version of dlib and installed latest version from dlib's github link and it's fixed. But I haven't understand how is 19.22 is newer version than 19.7.