| | |
| | | #include <basic/pipe_element/ffmpeg/VideoCaptureElement.h> |
| | | #include "ImageDrawElement.h" |
| | | #include "YoloRpcElement.h" |
| | | class Controllor : public PipeController |
| | | { |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | #include <basic/util/opencv/CvUtil.h> |
| | | |
| | | class Controllor : public PipeController { |
| | | public: |
| | | Controllor(const int index,const std::string& rtsp):m_videoCaptureElement(rtsp,25,1000,0), |
| | | m_YoloRpcElement(std::to_string(index)+"YoloRpc") |
| | | { |
| | | Controllor(const int index, const std::string &rtsp) : m_videoCaptureElement(rtsp, 25, -1, 0), |
| | | m_YoloRpcElement(std::to_string(index) + "YoloRpc") { |
| | | m_index = index; |
| | | m_rtsp = rtsp; |
| | | m_videoCaptureElement.registerConnector([&]{ |
| | | if(!m_YoloRpcElement.isBusy()){ |
| | | m_videoCaptureElement.registerConnector([&] { |
| | | if (!m_YoloRpcElement.isBusy()) { |
| | | m_YoloRpcElement.setImage(m_videoCaptureElement.getImage()); |
| | | // paElement.setImage(videoCaptureElement.getImage()); |
| | | // paNumElement.setImage(videoCaptureElement.getImage()); |
| | | // paElement.setImage(videoCaptureElement.getImage()); |
| | | // paNumElement.setImage(videoCaptureElement.getImage()); |
| | | m_YoloRpcElement.submit(); |
| | | } |
| | | if(!m_imageDrawElement.isBusy()){ |
| | | if (!m_imageDrawElement.isBusy()) { |
| | | m_imageDrawElement.setImage(m_videoCaptureElement.getImage()); |
| | | m_imageDrawElement.submit(); |
| | | } |
| | | }); |
| | | |
| | | m_YoloRpcElement.registerConnector([&]{ |
| | | m_imageDrawElement.setRects(m_YoloRpcElement.getRects()); |
| | | m_YoloRpcElement.registerConnector([&] { |
| | | m_imageDrawElement.setYoloObjects(m_YoloRpcElement.getLastScoreRects()); |
| | | }); |
| | | |
| | | m_imageDrawElement.registerConnector([&]{ |
| | | ImageShowElement::showImage(m_rtsp,*m_imageDrawElement.getImage()); |
| | | m_imageDrawElement.registerConnector([&] { |
| | | ImageShowElement::showImage(std::to_string(m_index), *m_imageDrawElement.getImage()); |
| | | |
| | | }); |
| | | m_videoCaptureElement.setOutPutInterval(2); |
| | | m_videoCaptureElement.setOutPutInterval(3); |
| | | registerElement(m_videoCaptureElement); |
| | | registerElement(m_YoloRpcElement); |
| | | registerElement(m_imageDrawElement); |
| | | } |
| | | virtual ~Controllor() |
| | | {} |
| | | |
| | | virtual ~Controllor() {} |
| | | |
| | | private: |
| | | std::string m_rtsp; |
| | | ffmpeg::VideoCaptureElement m_videoCaptureElement; |
| | | YoloRpcElement m_YoloRpcElement; |
| | | ImageDrawElement m_imageDrawElement; |
| | | int m_index; |
| | | }; |
| | | |
| | | using namespace std; |
| | | int main(int argc, char *argv[]) |
| | | { |
| | | SAVE_APP_ARGS |
| | | Controllor _Controllor(0,"/home/basic/video/201804/day0416/01010002606000000-slice1.mp4"); |
| | | _Controllor.start(); |
| | | void darwProperty(cv::Mat &image, string key, string value, int x, int y) { |
| | | cv::putText(image, key + ": " + value, cv::Point(x, y), cv::HersheyFonts::FONT_HERSHEY_PLAIN, 1.5, |
| | | cv::Scalar(255, 255, 0), 2); |
| | | } |
| | | |
| | | Controllor _Controllor0(1,"/home/basic/video/201804/day0416/01010002606000000-slice2.mp4"); |
| | | _Controllor0.start(); |
| | | cout << "Hello World!" << endl; |
| | | Controllor _Controllor1(2,"/home/basic/video/201804/day0416/01010002609000000-slice.mp4"); |
| | | _Controllor1.start(); |
| | | Controllor _Controllor2(3,"/home/basic/video/201804/day0416/01010002611000000-slice.mp4"); |
| | | _Controllor2.start(); |
| | | Controllor _Controllor3(4,"/home/basic/video/201804/night0418/02000000652000100-slice.mp4"); |
| | | _Controllor3.start(); |
| | | Controllor _Controllor4(5,"/home/basic/video/201804/night0418/02000000654000100-slice.mp4"); |
| | | _Controllor4.start(); |
| | | Controllor _Controllor5(6,"/home/basic/video/201804/night0418/02000000659000100-slice.mp4"); |
| | | _Controllor5.start(); |
| | | while(true) |
| | | {sleep(1);} |
| | | //using namespace std; |
| | | int main(int argc, char *argv[]) { |
| | | SAVE_APP_ARGS |
| | | |
| | | // int num = atoi(argv[1]); |
| | | // std::string path(argv[2]); |
| | | // int portNum = atoi(argv[3]); |
| | | //yolo server |
| | | appPref.setStringData("yolo.proxy", "yoloServer"); |
| | | //#todo |
| | | appPref.setStringData("yolo.ip", ""); |
| | | appPref.setIntData("yolo.port", 10003); |
| | | // rpcClient(appPref.getStringData("yolo.proxy"), appPref.getStringData("yolo.ip"), appPref.getLongData("yolo.port"),"tcp"), |
| | | |
| | | Controllor *_Controllor = new Controllor(1, "/home/bsk/210235C23NF187000045$2019-02-28-23-07-30_209850_210049.mp4"); |
| | | _Controllor->start(); |
| | | |
| | | getchar(); |
| | | |
| | | |
| | | |
| | | |
| | | YoloRpcElement m_YoloRpcElement("YoloRpc"); |
| | | ImageDrawElement m_imageDrawElement; |
| | | m_YoloRpcElement.start(); |
| | | m_imageDrawElement.start(); |
| | | auto img = cv::imread("/home/bsk/Desktop/wubao2.jpg"); |
| | | m_YoloRpcElement.setImage(img); |
| | | m_YoloRpcElement.submit(); |
| | | m_YoloRpcElement.registerConnector([&] { |
| | | }); |
| | | |
| | | sleep(2); |
| | | |
| | | auto res = m_YoloRpcElement.getLastScoreRects(); |
| | | |
| | | for (auto yoloObj: res) { |
| | | auto rect = CvUtil::zoomRect(yoloObj.rect, 1, 1); |
| | | //[{"x":1.5999756,"y":82.533325},{"x":1.5999756,"y":180.53333},{"x":61.599976,"y":175.53333},{"x":63.599976,"y":66.533325}] |
| | | //cv::rectangle(image, cv::Rect(4,328,252,480 ), cv::Scalar(0, 0, 255), 2); |
| | | cv::rectangle(img, rect, yoloObj.id >= 0 ? cv::Scalar(255, 0, 0) : cv::Scalar(0, 255, 255), 2); |
| | | int i = 0; |
| | | for (auto &property:yoloObj.properties) { |
| | | darwProperty(img, property.first, property.second, rect.x + rect.width, rect.y + 40 * i++); |
| | | } |
| | | } |
| | | cv::imwrite("img/test2.jpg", img); |
| | | cv::imshow("test", img); |
| | | // for (int i = 0; i < num; i++) { |
| | | // Controllor *_Controllor = new Controllor(i, path); |
| | | // _Controllor->start(); |
| | | // } |
| | | |
| | | // Controllor _Controllor(0, "/home/bsk/2.mp4"); |
| | | // _Controllor.start(); |
| | | // Controllor _Controllor1(1, "/home/bsk/2.mp4"); |
| | | // _Controllor1.start(); |
| | | // Controllor _Controllor2(2, "/home/bsk/2.mp4"); |
| | | // _Controllor2.start(); |
| | | // Controllor _Controllor3(3, "/home/bsk/2.mp4"); |
| | | // _Controllor3.start(); |
| | | // Controllor _Controllor4(4, "/home/bsk/2.mp4"); |
| | | // _Controllor4.start(); |
| | | |
| | | // Controllor _Controllor0(1,"/home/basic/video/201804/day0416/01010002606000000-slice2.mp4"); |
| | | // _Controllor0.start(); |
| | | // cout << "Hello World!" << endl; |
| | | // Controllor _Controllor1(2,"/home/basic/video/201804/day0416/01010002609000000-slice.mp4"); |
| | | // _Controllor1.start(); |
| | | // Controllor _Controllor2(3,"/home/basic/video/201804/day0416/01010002611000000-slice.mp4"); |
| | | // _Controllor2.start(); |
| | | // Controllor _Controllor3(4,"/home/basic/video/201804/night0418/02000000652000100-slice.mp4"); |
| | | // _Controllor3.start(); |
| | | // Controllor _Controllor4(5,"/home/basic/video/201804/night0418/02000000654000100-slice.mp4"); |
| | | // _Controllor4.start(); |
| | | // Controllor _Controllor5(6,"/home/basic/video/201804/night0418/02000000659000100-slice.mp4"); |
| | | // _Controllor5.start(); |
| | | while (true) { sleep(10); } |
| | | return 0; |
| | | } |