I try to run a neural network using OpenCV with OpenVino but face an error LNK2001 unresolved external symbol __imp_PathIsRelativeA
void TestOpenVinoModel()
{
// Model
string mapping_path = "C:\\ROOT1\\opencv_build_test\\files_openvino_2\\ssdlite_mobilenet_v2.mapping";
string xml_path = "C:\\ROOT1\\opencv_build_test\\files_openvino_2\\ssdlite_mobilenet_v2.xml";
string bin_path = "C:\\ROOT1\\opencv_build_test\\files_openvino_2\\ssdlite_mobilenet_v2.bin";
// Load the OpenVINO plugin for OpenCV
Net openvino_model = readNetFromModelOptimizer(xml_path, bin_path);
// Set target device to CPU
openvino_model.setPreferableTarget(DNN_TARGET_CPU);
// Load an image
Mat img = imread("C:\\ROOT1\\opencv_build_test\\car_300x300.jpg");
// Preprocess the image
//Mat blob = blobFromImage(img, 1.0, Size(), Scalar(), true, false);
Mat blob = blobFromImage(img, 0.007843f, Size(300, 300), Scalar(127.5f, 127.5f, 127.5f), false);
//Mat blob;
//cvtColor(img, blob, COLOR_BGR2RGB);
//blob = blob.reshape(1, { 1, 3, 300, 300 });
// Set input data for the network
openvino_model.setInput(blob);
// Run forward pass to get the output
Mat detections = openvino_model.forward();
// Post-process the output to extract the bounding boxes
Mat detections_reshaped = detections.reshape(1, detections.total() / 7);
// Draw bounding boxes on the original image
for (int i = 0; i < detections_reshaped.rows; ++i) {
float confidence = detections_reshaped.at<float>(i, 2);
if (confidence > 0.5) {
int x_left = static_cast<int>(detections_reshaped.at<float>(i, 3) * img.cols);
int y_top = static_cast<int>(detections_reshaped.at<float>(i, 4) * img.rows);
int x_right = static_cast<int>(detections_reshaped.at<float>(i, 5) * img.cols);
int y_bottom = static_cast<int>(detections_reshaped.at<float>(i, 6) * img.rows);
rectangle(img, Point(x_left, y_top), Point(x_right, y_bottom), Scalar(0, 0, 255), 2);
}
}
// Display the resulting image
imshow("Image", img);
waitKey();
}
int main()
{
TestOpenVinoModel();
return 0;
}
I built OpenVino from sources and then built OpenCV. I added all libs that OpenCV needed. I develop the program in Visual Studio 2022 with Runtime library Multi-threaded DLL (/MD).