-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
67 lines (65 loc) · 2.48 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include "VM_RTSPServer.h"
#include "VM_RTSPToImage.h"
#include "VM_YOLO.h"
#include "VM_ThreadSafeList.h"
void rtsp_to_image_thread(std::vector<VM_Buffer> rtspURLs) {
VM_RTSPToImage r2i(rtspURLs);
r2i.Init();
r2i.Invoke();
}
int main(){
// std::cout<<"start VideoMonitorServer..."<<std::endl;
// VM_RTSPServer server;
// server.Init();
// server.Invoke();
// std::cout<<"press anykey to stop..."<<std::endl;
// getchar();
// server.Stop();
// std::cout<<"test rtsp stream to images..."<<std::endl;
std::vector<VM_Buffer> rtspURLs;
//rtspURLs.push_back("rtsp://stream.strba.sk:1935/strba/VYHLAD_JAZERO.stream");
rtspURLs.push_back("rtsp://stream.strba.sk:1935/strba/VYHLAD_JAZERO.stream");
rtspURLs.push_back("rtsp://user:[email protected]/Streaming/Channels/101");
rtspURLs.push_back("rtsp://user:[email protected]/Streaming/Channels/102");
// VM_RTSPToImage r2i(rtspURLs);
// r2i.Init();
// r2i.Invoke();
std::thread rtspThread(rtsp_to_image_thread, rtspURLs);
std::string onnx_file_path = std::string(PROJECT_ROOT_DIR) + "/models/yolov11n.onnx";
std::string trt_file_path = std::string(PROJECT_ROOT_DIR) + "/models/yolov11n_8.4.3.1.trt";
//std::string input_image_path = std::string(PROJECT_ROOT_DIR) + "/sources/images/bus.jpg";
//std::string output_image_path = std::string(PROJECT_ROOT_DIR) + "/sources/images/out_bus.jpg";
int batch_size = 1;
int channel = 3;
int width = 640;
int height = 640;
YOLO yolo(onnx_file_path,trt_file_path,batch_size,channel,width,height);
//cv::Mat img = cv::imread(input_image_path);
//yolo.Inference(img,output_image_path);
VM_RTSPToImage::StructDeliveryData data;
cv::Mat img;
int count=1;
std::string output_image_path = std::string(PROJECT_ROOT_DIR) + "/sources/SaveFrame/yolo/";
while(1)
{
if(VM_RTSPToImage::delivery_list.empty())
{
usleep(100);
continue;
}
std::cout<<"count: "<<count<<std::endl;
VM_RTSPToImage::delivery_list.pop(data);
int batch_size = 1;
int channel = 3;
int width = data.width_gpu_srcImage;
int height = data.height_gpu_srcImage;
img = data.srcImage;
//std::cout<<"rtsp: "<<data.rtsp_path<<std::endl;
yolo.Inference(img,output_image_path + std::to_string(count)+".jpg");
count++;
}
std::cout<<"over~~"<<std::endl;
rtspThread.join();
return 0;
}