#include <iostream>
#include "acl/acl.h"
#include <pthread.h>
#include <thread>
#include <queue>
#include <opencv2/opencv.hpp>
using namespace std;
struct img_data
{
int classid;
cv::Mat frame;
float score;
};
struct image_rgb
{
cv::Mat image;
};
void yolo(cv::VideoCapture capture,aclrtContext context,queue<img_data>*yolo_queue)
{
while (cap.read(yolo_queue.frame))
{
}
}
void deeplabv(aclrtContext context,queue<img_data>*yolo_queue)
{
while (1)
{
cout<<"开始分割"<<endl;
}
}
int main(int argc, char *argv[])
{
//acl 初始化
const char *aclpath="./acl.json";
aclError ret = aclInit(aclpath);
//绑定devcie
int g_deviceId_ = 0;
ret = aclrtSetDevice(g_deviceId_);
//显示创建context
aclrtContext context;
aclrtGetCurrentContext(&context);
//创建全局队列
queue<img_data>yolo_queue;
// queue<image_rgb>deeplabv_queue;
//获取输入视频
const char *rtsppatch="./detection.mp4";
cv::VideoCapture capture(rtsppatch);
//开启两个线程
thread detect(yolo,ref(capture),ref(context),&yolo_queue);
thread deep(deeplabv,ref(context),&yolo_queue);
detect.join();
deep.join();
return 0;
}
1.对于官网中提到的多线程多stream管理机制,在多线程中必须要显示创建stream?
2.对于以上样例,我的两个线程中使用了同一个context,那在我的两个线程中是默认创建了两个stream?

这个图片的代码,在线程中获取主进程的context,是跟我上面的代码一样的道理?
#include <iostream>
#include "acl/acl.h"
#include <pthread.h>
#include <thread>
#include <queue>
#include <opencv2/opencv.hpp>
using namespace std;
struct img_data
{
int classid;
cv::Mat frame;
float score;
};
struct image_rgb
{
cv::Mat image;
};
void yolo(cv::VideoCapture capture,aclrtContext context,queue<img_data>*yolo_queue)
{
while (cap.read(yolo_queue.frame))
{
}
}
void deeplabv(aclrtContext context,queue<img_data>*yolo_queue)
{
while (1)
{
cout<<"开始分割"<<endl;
}
}
int main(int argc, char *argv[])
{
//acl 初始化
const char *aclpath="./acl.json";
aclError ret = aclInit(aclpath);
//绑定devcie
int g_deviceId_ = 0;
ret = aclrtSetDevice(g_deviceId_);
//显示创建context
aclrtContext context;
aclrtGetCurrentContext(&context);
//创建全局队列
queue<img_data>yolo_queue;
// queue<image_rgb>deeplabv_queue;
//获取输入视频
const char *rtsppatch="./detection.mp4";
cv::VideoCapture capture(rtsppatch);
//开启两个线程
thread detect(yolo,ref(capture),ref(context),&yolo_queue);
thread deep(deeplabv,ref(context),&yolo_queue);
detect.join();
deep.join();
return 0;
}
1.对于官网中提到的多线程多stream管理机制,在多线程中必须要显示创建stream?
2.对于以上样例,我的两个线程中使用了同一个context,那在我的两个线程中是默认创建了两个stream?
这个图片的代码,在线程中获取主进程的context,是跟我上面的代码一样的道理?