Detect
Detect
Detect
h>
#include <opencv2/opencv.hpp> // Include the OpenCV header
int main() {
std::string model_path = "/home/ubuntu/exported_model.pt";
std::string video_path = "/home/ubuntu/Downloads/remmie.mp4";
try {
// Load the TorchScript model
torch::jit::script::Module model;
model = torch::jit::load(model_path);
std::cout << "Model is Loaded Successfully" << std::endl;
model.eval();
// Extract bounding box coordinates and class labels from the detection
results
auto output = outputTensor.accessor<float, 2>();
std::vector<cv::Rect> boxes;
std::vector<int> labels;
for (int i = 0; i < output.size(0); i++) {
float label = output[i][0];
float xmin = output[i][1] * frame.cols;
float ymin = output[i][2] * frame.rows;
float xmax = output[i][3] * frame.cols;
float ymax = output[i][4] * frame.rows;
return 0;
}