فهرست منبع

add picview_usbport. for get usb camera's usb port info.

yuchuli 3 ماه پیش
والد
کامیت
c5cc8c49f5

+ 146 - 0
src/driver/driver_camera_usb/assignvideo.cpp

@@ -0,0 +1,146 @@
+#include "assignvideo.h"
+
+#include <iostream>
+#include <thread>
+
+
+#include <iostream>
+#include <vector>
+#include <sstream>
+#include <string>
+
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <linux/videodev2.h>
+#include <glob.h>
+
+using namespace std;
+
+
+vector<string> find_cameras() {
+    vector<string> devices;
+    glob_t glob_buf;
+
+    // 扫描/dev目录下的video设备‌:ml-citation{ref="1" data="citationList"}
+    if (glob("/dev/video*", GLOB_ERR, NULL, &glob_buf) == 0) {
+        for (size_t i = 0; i < glob_buf.gl_pathc; ++i) {
+            const char* dev_path = glob_buf.gl_pathv[i];
+
+            // 尝试打开设备
+            int fd = open(dev_path, O_RDONLY);
+            if (fd == -1) continue;
+
+            // 查询设备能力
+            v4l2_capability cap;
+            if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) {
+                if (cap.device_caps & V4L2_CAP_VIDEO_CAPTURE) {
+                    devices.push_back(dev_path);
+                }
+            }
+            close(fd);
+        }
+    }
+    globfree(&glob_buf);
+    return devices;
+}
+
+vector<string> splitBySlash(const string& str) {
+    vector<string> tokens;
+    size_t start = 0;
+    size_t end = str.find('/');
+
+    while (end != string::npos) {
+        tokens.push_back(str.substr(start, end - start));
+        start = end + 1;
+        end = str.find('/', start);
+    }
+    tokens.push_back(str.substr(start)); // 处理最后一个片段
+    return tokens;
+}
+
+vector<vector<string>> splitString(const string& input) {
+    vector<vector<string>> result;
+    // 第一步:按换行符拆分成多行‌:ml-citation{ref="1,5" data="citationList"}
+    istringstream lineStream(input);
+    string line;
+
+    while (getline(lineStream, line, '\n')) {
+        // 第二步:按空格或Tab拆分单词‌:ml-citation{ref="2,3" data="citationList"}
+        vector<string> words;
+        istringstream wordStream(line);
+        string word;
+
+        while (wordStream >> word) {
+            words.push_back(word);
+        }
+        result.push_back(words);
+    }
+    return result;
+}
+
+assignvideo::assignvideo()
+{
+
+}
+
+std::string assignvideo::GetVideoName(std::string usbport)
+{
+
+    while(mbRun)
+    {
+        char buffer[128];
+            std::string result;
+            FILE* pipe = popen("sh -c 'cd /sys/class/video4linux && ls -l'", "r");
+            if (!pipe) throw std::runtime_error("popen() failed!");
+            while (fgets(buffer, sizeof(buffer), pipe) != NULL) {
+                result += buffer;
+            }
+            pclose(pipe);
+            std::cout<<"result: \n"<<result<<std::endl;
+
+            vector<string> cameras = find_cameras();
+            vector<vector<string>> vecres = splitString(result);
+
+            int nsize = static_cast<int>(vecres.size());
+            int i;
+            for(i=0;i<nsize;i++)
+            {
+                if(static_cast<int>(vecres[i].size()) > 5)
+                {
+                    std::string str1 = vecres[i].at(vecres[i].size() - 1);
+                    vector<string> vecstr2 = splitBySlash(str1);
+                    if(vecstr2.size()>5)
+                    {
+                        std::string str3 = vecstr2[vecstr2.size() -4];
+                        std::string strvideoname = vecstr2[vecstr2.size() - 1];
+                        if(str3 == usbport)
+                        {
+                            std::string strdevname = std::string("/dev/") + strvideoname;
+                            bool bcamera = false;
+                            for(auto strcamera : cameras){
+                                if(strdevname == strcamera){
+                                    bcamera = true;
+                                    break;
+                                }
+                            }
+                            if(bcamera){
+                                return strdevname;
+   //                             std::cout<<" camera"<<std::endl;
+                            }
+                            if(bcamera == false)
+                            {
+  //                              std::cout<<" is not a video. "<<std::endl;
+                            }
+                        }
+                    }
+
+                }
+            }
+
+            std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+    }
+
+    return std::string("");
+}

+ 20 - 0
src/driver/driver_camera_usb/assignvideo.h

@@ -0,0 +1,20 @@
+#ifndef ASSIGNVIDEO_H
+#define ASSIGNVIDEO_H
+
+#include <string>
+#include "signal.h"
+
+#include <QProcess>
+
+class assignvideo
+{
+public:
+    assignvideo();
+
+    std::string GetVideoName(std::string usbport);
+
+private:
+    bool mbRun = true;
+};
+
+#endif // ASSIGNVIDEO_H

+ 4 - 2
src/driver/driver_camera_usb/driver_camera_usb.pro

@@ -16,7 +16,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
 SOURCES += main.cpp \
-    ../../include/msgtype/rawpic.pb.cc
+    ../../include/msgtype/rawpic.pb.cc \
+    assignvideo.cpp
 
 
 !include(../../../include/common.pri ) {
@@ -41,7 +42,8 @@ contains(QMAKE_HOST.arch, aarch64){
 
 
 HEADERS += \
-    ../../include/msgtype/rawpic.pb.h
+    ../../include/msgtype/rawpic.pb.h \
+    assignvideo.h
 
 LIBS += -lavcodec -lavformat -lavutil
 

+ 5 - 1
src/driver/driver_camera_usb/main.cpp

@@ -30,6 +30,8 @@ extern "C"
 
 #include "ivversion.h"
 
+#include "assignvideo.h"
+
 void * gpa;
 
 int gindex = 0;
@@ -288,7 +290,9 @@ void testthread()
 int main(int argc, char *argv[])
 {
 
-
+    assignvideo xvid;
+    std::string strdevname = xvid.GetVideoName(std::string("1-4.2.4"));
+    std::cout<<" dev name: "<<strdevname<<std::endl;
 
     showversion("driver_camera_usb");
     QCoreApplication a(argc, argv);

+ 7 - 0
src/driver/driver_h264_enc/main.cpp

@@ -173,6 +173,8 @@ void ThreadEnc()
 
      c = avcodec_alloc_context3(codec);
 
+
+
      if(c == NULL)std::cout<<"c NULL ."<<std::endl;
      pkt = av_packet_alloc();
          if (!pkt)
@@ -220,6 +222,11 @@ void ThreadEnc()
 //             av_opt_set(c->priv_data,"look_ahead_downsampling","off",0);
          }
 
+
+//         AVBufferRef * pref;
+
+ //        avcodec_set_hw_device_context(c, av_hwdevice_ctx_create(&pref,AV_HWDEVICE_TYPE_CUDA,  nullptr, nullptr, 0));
+
           /* open it */
           ret = avcodec_open2(c, codec, NULL);
           if (ret < 0) {

+ 16 - 0
src/tool/picview_usbport/main.cpp

@@ -0,0 +1,16 @@
+#include "mainwindow.h"
+#include <QApplication>
+
+#include "ivversion.h"
+#include "ivbacktrace.h"
+
+int main(int argc, char *argv[])
+{
+    RegisterIVBackTrace();
+    showversion("picview");
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+
+    return a.exec();
+}

+ 655 - 0
src/tool/picview_usbport/mainwindow.cpp

@@ -0,0 +1,655 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+#include <opencv2/opencv.hpp>
+#include <opencv2/core.hpp>
+
+#include <opencv2/imgproc.hpp>
+
+//#include "opencv2/imgcodecs/legacy/constants_c.h"
+#include <opencv2/imgproc/types_c.h>
+
+#include "xmlparam.h"
+
+MainWindow * gw;
+qint64 xt;
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <linux/videodev2.h>
+#include <glob.h>
+
+#include "usb_cam.h"
+
+using namespace std;
+
+
+vector<string> find_cameras() {
+    vector<string> devices;
+    glob_t glob_buf;
+
+    // 扫描/dev目录下的video设备‌:ml-citation{ref="1" data="citationList"}
+    if (glob("/dev/video*", GLOB_ERR, NULL, &glob_buf) == 0) {
+        for (size_t i = 0; i < glob_buf.gl_pathc; ++i) {
+            const char* dev_path = glob_buf.gl_pathv[i];
+
+            // 尝试打开设备
+            int fd = open(dev_path, O_RDONLY);
+            if (fd == -1) continue;
+
+            // 查询设备能力
+            v4l2_capability cap;
+            if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) {
+                if (cap.device_caps & V4L2_CAP_VIDEO_CAPTURE) {
+                    devices.push_back(dev_path);
+                }
+            }
+            close(fd);
+        }
+    }
+    globfree(&glob_buf);
+    return devices;
+}
+
+vector<string> splitBySlash(const string& str) {
+    vector<string> tokens;
+    size_t start = 0;
+    size_t end = str.find('/');
+
+    while (end != string::npos) {
+        tokens.push_back(str.substr(start, end - start));
+        start = end + 1;
+        end = str.find('/', start);
+    }
+    tokens.push_back(str.substr(start)); // 处理最后一个片段
+    return tokens;
+}
+
+vector<vector<string>> splitString(const string& input) {
+    vector<vector<string>> result;
+    // 第一步:按换行符拆分成多行‌:ml-citation{ref="1,5" data="citationList"}
+    istringstream lineStream(input);
+    string line;
+
+    while (getline(lineStream, line, '\n')) {
+        // 第二步:按空格或Tab拆分单词‌:ml-citation{ref="2,3" data="citationList"}
+        vector<string> words;
+        istringstream wordStream(line);
+        string word;
+
+        while (wordStream >> word) {
+            words.push_back(word);
+        }
+        result.push_back(words);
+    }
+    return result;
+}
+
+MainWindow::MainWindow(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+
+    SearchCamera();
+
+    gw = this;
+    mTime.start();
+    mnlidarcount = 0;
+    mnonepcd = 0;
+    mbSaveOne = false;
+    mbSave = false;
+    mnsave = 0;
+
+    mbOpen = false;
+
+    mstrSavePath = QCoreApplication::applicationDirPath();
+
+    myview = new MyView(this);
+    myview->setObjectName(QStringLiteral("graphicsView"));
+    myview->setGeometry(QRect(30, 30, 600, 600));
+
+    image = new QImage(2000, 2000, QImage::Format_RGB32);//画布的初始化大小设为300*300,使用32位颜色
+    myview->setCacheMode(myview->CacheBackground);
+
+    painter = new QPainter(image);
+    painter->end();
+
+    scene = new QGraphicsScene;
+
+    CreateView();
+
+    int i;
+    for(i=0;i<MAX_CAMERA;i++)
+    {
+        mpicindex[i] = 0;
+        mpicviewindex[i] = 0;
+    }
+
+    mCurCameraIndex = 0;
+
+//    myview->scale(0.3,0.3);
+//    myview->show();
+
+    QString strpath = QCoreApplication::applicationDirPath();
+
+
+        strpath = strpath + "/picview.xml";
+
+    std::cout<<strpath.toStdString()<<std::endl;
+    iv::xmlparam::Xmlparam xp(strpath.toStdString());
+
+
+    connect(&mTimer,SIGNAL(timeout()),this,SLOT(onTimer()));
+    connect(this,SIGNAL(updatepic()),this,SLOT(onTimer()));
+#ifdef Q_OS_WIN32
+    mTimer.start(1000);
+#else
+    mTimer.start(300);
+#endif
+
+    setWindowTitle("picview");
+
+}
+
+MainWindow::~MainWindow()
+{
+    if(mbthreadrun)
+    {
+        mbthreadrun = false;
+        mpthreadcam->join();
+    }
+    delete ui;
+}
+
+
+void MainWindow::SearchCamera()
+{
+    vector<string> cameras = find_cameras();
+
+    char buffer[128];
+    std::string result;
+    FILE* pipe = popen("sh -c 'cd /sys/class/video4linux && ls -l'", "r");
+    if (!pipe) throw std::runtime_error("popen() failed!");
+    while (fgets(buffer, sizeof(buffer), pipe) != NULL) {
+        result += buffer;
+    }
+    pclose(pipe);
+    std::cout<<"result: \n"<<result<<std::endl;
+    vector<vector<string>> vecres = splitString(result);
+
+    std::vector<std::string> xvectorcameras;
+    std::vector<std::string> xvectorusbport;
+
+    for(std::string strcamera:cameras){
+        int nsize = static_cast<int>(vecres.size());
+        int i;
+        for(i=0;i<nsize;i++)
+        {
+            if(static_cast<int>(vecres[i].size()) > 5)
+            {
+                std::string str1 = vecres[i].at(vecres[i].size() - 1);
+                vector<string> vecstr2 = splitBySlash(str1);
+                if(vecstr2.size()>5)
+                {
+                    std::string str3 = vecstr2[vecstr2.size() -4];
+                    std::string strvideoname = vecstr2[vecstr2.size() - 1];
+                    std::string strdevname = std::string("/dev/") + strvideoname;
+                    if(strcamera == strdevname)
+                    {
+
+                        xvectorcameras.push_back(strcamera);
+                        xvectorusbport.push_back(str3);
+                    }
+                }
+
+            }
+        }
+    }
+
+    mvectorcameras = xvectorcameras;
+    mvectorusbport = xvectorusbport;
+}
+
+
+void MainWindow::UpdatePic(iv::vision::rawpic pic,int index)
+{
+    mMutex.lock();
+    mrectime = QDateTime::currentMSecsSinceEpoch();
+    mrawpics[index].CopyFrom(pic);
+ //   qDebug("timex is %ld ",mrawpic.time());
+
+
+    mpicindex[index]++;
+    mMutex.unlock();
+
+    if((mbSaveOne)&&(index == mCurCameraIndex))
+    {
+        QString strpath = mstrSavePath;
+        strpath = strpath+"/";
+        strpath = strpath + QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz") + ".jpg";
+   //     pcl::io::loadPCDFile<pcl::PointXYZRGBA>("table_scene_lms400.pcd", *cloud
+        SaveOnePic(strpath,index);
+        mbSaveOne = false;
+        mnonepcd++;
+
+    }
+
+    if((mbSave)&&(index == mCurCameraIndex))
+    {
+        QString strpath = mstrSavePath;
+        strpath = strpath+"/";
+        strpath = strpath + QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz") + ".jpg";
+        SaveOnePic(strpath,index);
+        mnsave++;
+
+    }
+    mnlidarcount++;
+
+    emit updatepic();
+
+
+
+}
+
+void MainWindow::UpdatePointCloud(pcl::PointCloud<pcl::PointXYZI>::Ptr pc)
+{
+    if(mbSaveOne)
+    {
+        QString strpath = mstrSavePath;
+        strpath = strpath+"/";
+        strpath = strpath + QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz") + "-1.pcd";
+   //     pcl::io::loadPCDFile<pcl::PointXYZRGBA>("table_scene_lms400.pcd", *cloud
+    }
+
+    if(mbSave)
+    {
+        QString strpath = mstrSavePath;
+        strpath = strpath+"/";
+        strpath = strpath + QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz") + ".pcd";
+
+    }
+    mMutex.lock();
+    mMutex.unlock();
+    mnlidarcount++;
+    mpLE_lidarcount->setText(QString::number(mnlidarcount));
+
+
+//    if(!pc->empty())update();
+}
+
+
+void MainWindow::on_checkBox_clicked()
+{
+
+}
+
+
+void MainWindow::onTimer()
+{
+    update();
+
+
+}
+
+//刷新
+void MainWindow::paintEvent(QPaintEvent *)
+{
+
+
+    if(mpicviewindex[mCurCameraIndex] == mpicindex[mCurCameraIndex])return;
+
+    mpicviewindex[mCurCameraIndex] = mpicindex[mCurCameraIndex];
+
+
+    mpLE_onepcd->setText(QString::number(mnonepcd));
+    mpLE_savepcd->setText(QString::number(mnsave));
+    mpLE_lidarcount->setText(QString::number(mnlidarcount));
+
+ //   qDebug("hear4.");
+    iv::vision::rawpic pic;
+    qint64 rectime;
+    mMutex.lock();
+    pic.CopyFrom(mrawpics[mCurCameraIndex]);
+    rectime = mrectime;
+    mMutex.unlock();
+
+//    qDebug("hear5.");
+
+
+    painter->begin(image);
+
+    image->fill(QColor(255, 255, 255));//对画布进行填充
+//    image->fill(QColor(0, 0, 0));//对画布进行填充
+//    std::vector<iv::GPSData> navigation_data = brain->navigation_data;
+    painter->setRenderHint(QPainter::Antialiasing, true);//设置反锯齿模式,好看一点
+
+    painter->translate(1000,1000);
+
+
+ //   std::string strpic = pic.picdata();
+
+//    int rows,cols,type;
+//    const char * pstr = strpic.data();
+//    memcpy(&rows,pstr+2,sizeof(int));
+//    memcpy(&cols,pstr+6,sizeof(int));
+//    memcpy(&type,pstr+10,sizeof(int));
+
+
+    
+    cv::Mat mat(pic.height(),pic.width(),pic.mattype());
+    
+    if(pic.type() == 1)
+        memcpy(mat.data,pic.picdata().data(),mat.rows*mat.cols*mat.elemSize());
+    else
+    {
+
+        qDebug("jpg");
+        std::vector<unsigned char> buff(pic.picdata().data(),pic.picdata().data()+pic.picdata().size());
+        mat = cv::imdecode(buff,1);
+    }
+ //   qDebug("pic len is %d ",strpic.length());
+
+
+
+
+    cv::cvtColor(mat, mat, CV_BGR2RGB);
+    QImage image2 = QImage((uchar*)(mat.data), mat.cols, mat.rows,  QImage::Format_RGB888);
+
+
+
+//    QImage image2 = QImage((uchar*)(mat.data), mat.cols, mat.rows,  QImage::Format_ARGB32);
+
+ //   QImage image2 = QImage((uchar*)(mat.data), mat.cols, mat.rows,  QImage::Format_RGBA8888);
+
+
+
+
+
+
+//    QColor x;
+//    x.setHsl(200,255,120);
+//    painter->setPen(x);
+//    painter->drawText(-300,-300,40,40,Qt::AlignHCenter | Qt::AlignTop,"hello");
+    painter->end();
+    scene->clear();
+    scene->addPixmap(QPixmap::fromImage(image2));
+    myview->setScene(scene);
+    myview->show();
+
+    mpLE_capturetime->setText(QString::number(pic.time()));
+
+ //   qint64 timediff = rectime - pic.time();
+    qint64 timediff = xt - pic.time();
+
+
+    mpLE_rectime->setText(QString::number(xt));
+    mpLE_timediff->setText(QString::number(timediff));
+
+
+    mat.release();
+}
+
+void MainWindow::resizeEvent(QResizeEvent *event)
+{
+    qDebug("resize");
+    QSize sizemain = ui->centralWidget->size();
+    qDebug("size x = %d y=%d",sizemain.width(),sizemain.height());
+
+    AdjustWPos(sizemain);
+
+}
+
+void MainWindow::AdjustWPos(QSize sizemain)
+{
+    myview->setGeometry(20,30,sizemain.width()-400,sizemain.height());
+    if((sizemain.width()-400)>0)
+    {
+        double fscale = (sizemain.width()-400)/640.0;
+        myview->viewscaleto(fscale);
+    }
+
+    mgplidar->setGeometry(sizemain.width()-350,30,320,400);
+}
+
+void MainWindow::CreateStatusView(QGridLayout *gl)
+{
+    gl->setSpacing(10);
+    int iRow = 0;
+
+    QLabel * pl = new QLabel(this);
+    pl->setText("Count");
+    pl->setFixedWidth(150);
+
+    QLineEdit * ple = new QLineEdit(this);
+    ple->setFixedWidth(150);
+
+    gl->addWidget(pl,iRow,0);
+    gl->addWidget(ple,iRow,1);
+    iRow++;
+
+    mpLE_lidarcount = ple;
+
+    QPushButton * pb2 = new QPushButton(this);
+    pb2->setText("Save One");
+    pb2->setFixedWidth(80);
+
+    QLineEdit * ple2 = new QLineEdit(this);
+    ple2->setFixedWidth(150);
+
+    gl->addWidget(pb2,iRow,0);
+    gl->addWidget(ple2,iRow,1);
+    iRow++;
+
+    mpPB_saveonepcd = pb2;
+    mpLE_onepcd = ple2;
+    connect(mpPB_saveonepcd,SIGNAL(clicked(bool)),this,SLOT(onSaveOnePCD()));
+
+    QPushButton * pb3 = new QPushButton(this);
+    pb3->setText("Start Save");
+    pb3->setFixedWidth(80);
+
+    QLineEdit * ple3 = new QLineEdit(this);
+    ple3->setFixedWidth(150);
+
+    gl->addWidget(pb3,iRow,0);
+    gl->addWidget(ple3,iRow,1);
+    iRow++;
+
+    mpPB_savepcd = pb3;
+    mpLE_savepcd = ple3;
+    connect(mpPB_savepcd,SIGNAL(clicked(bool)),this,SLOT(onSavePCD()));
+
+    QPushButton * pb4 = new QPushButton(this);
+    pb4->setText("Set Folder");
+    pb4->setFixedWidth(80);
+
+    QLineEdit * ple4 = new QLineEdit(this);
+    ple4->setFixedWidth(150);
+
+    gl->addWidget(pb4,iRow,0);
+    gl->addWidget(ple4,iRow,1);
+    iRow++;
+
+    mpLE_savefolder = ple4;
+    connect(pb4,SIGNAL(clicked(bool)),this,SLOT(onSelectFolder()));
+
+    QLabel * pl5 = new QLabel(this);
+    pl5->setText("capture time");
+    pl5->setFixedWidth(150);
+
+    QLineEdit * ple5 = new QLineEdit(this);
+    ple5->setFixedWidth(150);
+
+    gl->addWidget(pl5,iRow,0);
+    gl->addWidget(ple5,iRow,1);
+    iRow++;
+
+    mpLE_capturetime = ple5;
+
+    QLabel * pl6 = new QLabel(this);
+    pl6->setText("receive time");
+    pl6->setFixedWidth(150);
+
+    QLineEdit * ple6 = new QLineEdit(this);
+    ple6->setFixedWidth(150);
+
+    gl->addWidget(pl6,iRow,0);
+    gl->addWidget(ple6,iRow,1);
+    iRow++;
+
+    mpLE_rectime = ple6;
+
+
+    QLabel * pl7 = new QLabel(this);
+    pl7->setText("latence time");
+    pl7->setFixedWidth(150);
+
+    QLineEdit * ple7 = new QLineEdit(this);
+    ple7->setFixedWidth(150);
+
+    gl->addWidget(pl7,iRow,0);
+    gl->addWidget(ple7,iRow,1);
+    iRow++;
+
+    mpLE_timediff = ple7;
+
+    QComboBox * pcb = new QComboBox(this);
+    pcb->setFixedWidth(150);
+    gl->addWidget(pcb,iRow,0);
+
+    QLineEdit * plecb = new QLineEdit(this);
+    plecb->setReadOnly(true);
+    gl->addWidget(plecb,iRow,1);
+    mpLE_DevName = plecb;
+
+    iRow++;
+
+    for(std::string strusbport: mvectorusbport){
+        pcb->addItem(QString(strusbport.data()));
+    }
+
+    pcb->setCurrentIndex(0);
+    if(mvectorusbport.size()>0){
+        mpLE_DevName->setText(QString::fromStdString(mvectorcameras[0]));
+        mstrseldevname = mvectorcameras[0];
+        mbthreadrun = true;
+        mpthreadcam = new std::thread(&MainWindow::threadcam,this,0);
+
+    }
+    connect(pcb,SIGNAL(currentIndexChanged(int)),this,SLOT(onSelectCamera(int)));
+
+    QSpacerItem * xpsi2 = new QSpacerItem(400,1000,QSizePolicy::Maximum);
+
+    gl->addItem(xpsi2,iRow,0);
+}
+
+void MainWindow::CreateView()
+{
+    QGroupBox * gp1 = new QGroupBox(ui->centralWidget);
+    gp1->setTitle(QStringLiteral("IMAGE Status"));
+    gp1->setGeometry(QRect(10,100,400,600));
+    QGridLayout * gll1 = new QGridLayout(ui->centralWidget);
+    gp1->setLayout(gll1);
+
+    CreateStatusView(gll1);
+
+    mgplidar = gp1;
+}
+
+void MainWindow::onSaveOnePCD()
+{
+    mbSaveOne = true;
+}
+
+void MainWindow::onSavePCD()
+{
+    if(mbSave)
+    {
+        mbSave = false;
+        mpPB_savepcd->setText("Start Save");
+    }
+    else
+    {
+        mbSave = true;
+        mpPB_savepcd->setText("Stop Save");
+    }
+}
+
+void MainWindow::onSelectFolder()
+{
+    QString str = QFileDialog::getExistingDirectory(this, tr("Set PCD Save Directory"), mstrSavePath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+    if(!str.isEmpty())
+    {
+        mstrSavePath = str;
+        mpLE_savefolder->setText(mstrSavePath);
+
+    }
+    else
+    {
+        qDebug("not change dir.");
+    }
+}
+
+void MainWindow::SaveOnePic(QString strpath,int index)
+{
+    mMutex.lock();
+
+    cv::Mat mat(mrawpics[index].height(),mrawpics[index].width(),mrawpics[index].mattype());
+    if(mrawpics[index].type() == 1)
+        memcpy(mat.data,mrawpics[index].picdata().data(),mat.rows*mat.cols*mat.elemSize());
+    else
+    {
+
+        qDebug("save jpg");
+        std::vector<unsigned char> buff(mrawpics[index].picdata().data(),mrawpics[index].picdata().data()+mrawpics[index].picdata().size());
+        mat = cv::imdecode(buff,1);//mat = cv::imdecode(buff,CV_LOAD_IMAGE_COLOR);
+    }
+
+    cv::imwrite(strpath.toStdString(),mat);
+
+    mMutex.unlock();
+}
+
+void MainWindow::onSelectCamera(int index)
+{
+    mCurCameraIndex = index;
+    if((index>=0)&&(index < static_cast<int>(mvectorusbport.size()))){
+        mpLE_DevName->setText(QString::fromStdString(mvectorcameras[index]));
+        mstrseldevname = mvectorcameras[index];
+        mbthreadrun = false;
+        mpthreadcam->join();
+        mbthreadrun = true;
+        mpthreadcam = new std::thread(&MainWindow::threadcam,this,index);
+    }
+}
+
+void MainWindow::threadcam(int index){
+    std::string strdevname = mvectorcameras[index];
+    usb_cam::UsbCam camx;
+    using namespace  usb_cam;
+    // set the IO method
+    UsbCam::io_method io_method = UsbCam::io_method_from_string(std::string("mmap"));
+
+    // set the pixel format
+    UsbCam::pixel_format pixel_format = UsbCam::pixel_format_from_string("mjpeg");
+
+    // start the camera
+    camx.start(strdevname, io_method, pixel_format, 1920,
+               1080, 30);
+
+    char * strbuf = new char[10000000];
+    while(mbthreadrun)
+    {
+        int nLen;
+        camx.grab_image(strbuf,&nLen,10000000);
+        qDebug("time %ld len: %ld",QDateTime::currentMSecsSinceEpoch(),nLen);
+    }
+    delete strbuf;
+
+    camx.stop_capturing();
+
+    std::cout<<"thread capture close."<<std::endl;
+    // check auto white balance
+
+}

+ 239 - 0
src/tool/picview_usbport/mainwindow.h

@@ -0,0 +1,239 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+#include <QImage>
+#include <QGraphicsScene>
+#include <QTimer>
+#include <QPainter>
+#include <QMutex>
+#include <memory>
+
+#include <QDateTime>
+#include <QComboBox>
+
+#include <pcl/conversions.h>
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
+
+#include <QTimer>
+
+#include <QTime>
+
+#include <QGroupBox>
+#include <QGridLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+
+#include <QFileDialog>
+
+#include <thread>
+
+#include "myview.h"
+
+#include "modulecomm.h"
+#include "rawpic.pb.h"
+
+#define MAX_CAMERA 4
+
+namespace Ui {
+class MainWindow;
+}
+
+
+namespace iv {
+    const int grx = 200, gry = 550, centerx = 100, centery = 50;
+    const double gridwide = 0.2;
+    struct ObstacleBasic
+    {
+        bool valid;
+        float nomal_x;
+        float nomal_y;
+        float nomal_z;
+
+        float speed_relative;
+        float speed_x;
+        float speed_y;
+        float speed_z;
+
+        float high;
+        float low;
+
+        int esr_ID;
+    };
+
+//    typedef boost::shared_ptr<std::vector<iv::ObstacleBasic>> ObsLiDAR;
+//    typedef boost::shared_ptr<std::vector<iv::ObstacleBasic>> ObsRadar;
+//    typedef boost::shared_ptr<std::vector<iv::ObstacleBasic>> ObsCamera;
+//    typedef boost::shared_ptr<std::vector<iv::ObstacleBasic>>ObsRadarPointer;
+    struct Obs_grid
+    {
+        double high;
+        double low;
+        double obshight;
+        int pointcount;
+        int ob;//障碍物属性,0地面 ,1路沿,2障碍物
+    };
+
+    typedef Obs_grid LidarGrid;
+    typedef Obs_grid* LidarGridPtr;
+}
+
+class BBox
+{
+public:
+    double mcenter_x;
+    double mcenter_y;
+    double mydis;
+    double mxdis;
+    double xmin;
+    double ymin;
+    double xmax;
+    double ymax;
+    std::shared_ptr<std::vector<iv::ObstacleBasic>> mPC;
+    BBox(std::shared_ptr<std::vector<iv::ObstacleBasic>> ptrclu)
+    {
+        int nSize = ptrclu->size();
+        if(nSize < 1)return;
+        iv::ObstacleBasic x = ptrclu->at(0);
+        xmin = x.nomal_x;
+        xmax = x.nomal_x;
+        ymin = x.nomal_y;
+        ymax = ymin;
+        int i;
+        for(i=1;i<nSize;i++)
+        {
+            x = ptrclu->at(i);
+            if(x.nomal_x<xmin)xmin = x.nomal_x;
+            if(x.nomal_x>xmax)xmax = x.nomal_x;
+            if(x.nomal_y<ymin)ymin = x.nomal_y;
+            if(x.nomal_y>ymax)ymax = x.nomal_y;
+        }
+        mydis = ymax - ymin+0.2;
+        mxdis = xmax - xmin+0.2;
+        mcenter_x = xmin + mxdis/2.0;
+        mcenter_y = ymin + mydis/2.0;
+
+        mPC.swap(ptrclu);
+//        std::cout<<"box x="<<mcenter_x<<" y="<<mcenter_y<<" xdis ="<<mxdis<<" ydis = "<<mydis<<" point count ="<<nSize<<std::endl;
+
+    }
+
+
+};
+
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit MainWindow(QWidget *parent = 0);
+    ~MainWindow();
+    QTime mTime;
+
+    void UpdatePointCloud(pcl::PointCloud<pcl::PointXYZI>::Ptr pc);
+
+    void UpdatePic(iv::vision::rawpic pic,int index);
+
+private slots:
+    void on_checkBox_clicked();
+    void onTimer();
+    virtual void paintEvent(QPaintEvent *);
+
+    void onSelectCamera(int index);
+
+private:
+    Ui::MainWindow *ui;
+
+    bool mbOpen;
+    void * mpa;
+
+
+    unsigned char mbmpLD[400*600*4];
+
+    QImage *image;
+    QPainter *painter;
+    MyView *myview;
+    QTimer *timer;
+    QGraphicsScene *scene;
+
+
+
+    QTimer mTimer;
+
+    QMutex mMutex;
+    QMutex mMutexPer;
+
+    int mCurCameraIndex;
+
+    pcl::PointCloud<pcl::PointXYZI>::Ptr mpoint_cloud;
+
+public:
+     void resizeEvent(QResizeEvent *event);
+
+private:
+     void AdjustWPos(QSize sizemain);
+
+     void CreateStatusView(QGridLayout * gl);
+     void CreateView();
+     void SearchCamera();
+     QGroupBox * mgplidar;
+     QLineEdit * mpLE_lidarcount;
+     int mnlidarcount;
+     QPushButton * mpPB_saveonepcd;
+     QPushButton * mpPB_savepcd;
+     QLineEdit * mpLE_onepcd;
+     QLineEdit * mpLE_savepcd;
+     int mnonepcd;
+     bool mbSaveOne;
+     bool mbSave;
+     int mnsave;
+     QLineEdit * mpLE_savefolder;
+ //    iv::vision::rawpic mrawpic;
+     iv::vision::rawpic mrawpics[MAX_CAMERA];
+     int mpicindex[MAX_CAMERA];
+     int mpicviewindex[MAX_CAMERA];
+
+     void SaveOnePic(QString strpath,int index);
+
+     QLineEdit * mpLE_capturetime;
+     QLineEdit * mpLE_rectime;
+     QLineEdit * mpLE_timediff;
+
+     QLineEdit * mpLE_DevName;
+
+     qint64 mrectime;
+
+     std::vector<std::string> mvectorcameras;
+     std::vector<std::string> mvectorusbport;
+
+     std::thread * mpthreadcam;
+     bool mbthreadrun = true;
+
+     std::string mstrseldevname;
+
+signals:
+     void updatepic();
+
+
+public slots:
+     void onSaveOnePCD();
+     void onSavePCD();
+     void onSelectFolder();
+
+private:
+     QString mstrSavePath;
+
+private:
+     void threadcam(int index);
+
+
+
+
+
+};
+
+#endif // MAINWINDOW_H

+ 40 - 0
src/tool/picview_usbport/mainwindow.ui

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>752</width>
+    <height>450</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralWidget"/>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>752</width>
+     <height>28</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>

+ 414 - 0
src/tool/picview_usbport/moc_predefs.h

@@ -0,0 +1,414 @@
+#define __SSP_STRONG__ 3
+#define __DBL_MIN_EXP__ (-1021)
+#define __LDBL_MANT_DIG__ 113
+#define __cpp_attributes 200809L
+#define __UINT_LEAST16_MAX__ 0xffff
+#define __ARM_SIZEOF_WCHAR_T 4
+#define __DBL_DECIMAL_DIG__ 17
+#define __ATOMIC_ACQUIRE 2
+#define __FLT128_MAX_10_EXP__ 4932
+#define __FLT_MIN__ 1.17549435082228750796873653722224568e-38F
+#define __GCC_IEC_559_COMPLEX 2
+#define __cpp_aggregate_nsdmi 201304L
+#define __UINT_LEAST8_TYPE__ unsigned char
+#define __FLT128_DIG__ 33
+#define __INTMAX_C(c) c ## L
+#define __CHAR_BIT__ 8
+#define __UINT8_MAX__ 0xff
+#define __cpp_static_assert 200410L
+#define __WCHAR_MAX__ 0xffffffffU
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
+#define __GCC_IEC_559 2
+#define __FLT32X_DECIMAL_DIG__ 17
+#define __FLT_EVAL_METHOD__ 0
+#define __cpp_binary_literals 201304L
+#define __FLT64_DECIMAL_DIG__ 17
+#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
+#define __cpp_variadic_templates 200704L
+#define __UINT_FAST32_TYPE__ long unsigned int
+#define __UINT_FAST64_MAX__ 0xffffffffffffffffUL
+#define __SIG_ATOMIC_TYPE__ int
+#define __DBL_MIN_10_EXP__ (-307)
+#define __FINITE_MATH_ONLY__ 0
+#define __cpp_variable_templates 201304L
+#define __FLT32X_MAX_EXP__ 1024
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+#define __GNUC_PATCHLEVEL__ 0
+#define __FLT32_HAS_DENORM__ 1
+#define __UINT_FAST8_MAX__ 0xff
+#define __cpp_rvalue_reference 200610L
+#define __INT8_C(c) c
+#define __INT_LEAST8_WIDTH__ 8
+#define __INTMAX_TYPE__ long int
+#define __UINT_LEAST64_MAX__ 0xffffffffffffffffUL
+#define __INT_LEAST8_MAX__ 0x7f
+#define __SHRT_MAX__ 0x7fff
+#define __STDC_ISO_10646__ 201706L
+#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
+#define __ARM_FEATURE_IDIV 1
+#define __FLT64X_MAX_10_EXP__ 4932
+#define __LDBL_IS_IEC_60559__ 2
+#define __ARM_FP 14
+#define __FLT64X_IS_IEC_60559__ 2
+#define __FLT64X_HAS_QUIET_NAN__ 1
+#define __WINT_TYPE__ unsigned int
+#define __UINT_LEAST8_MAX__ 0xff
+#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F128
+#define __UINTMAX_TYPE__ long unsigned int
+#define _STDC_PREDEF_H 1
+#define __cpp_nsdmi 200809L
+#define __linux 1
+#define __CHAR_UNSIGNED__ 1
+#define __UINT32_MAX__ 0xffffffffU
+#define __DBL_DENORM_MIN__ double(4.94065645841246544176568792868221372e-324L)
+#define __AARCH64_CMODEL_SMALL__ 1
+#define __LDBL_MAX_EXP__ 16384
+#define __INT_FAST32_WIDTH__ 64
+#define __FLT128_MIN_EXP__ (-16381)
+#define __FLT128_MIN_10_EXP__ (-4931)
+#define __FLT32X_IS_IEC_60559__ 2
+#define __INT_LEAST16_WIDTH__ 16
+#define __SCHAR_MAX__ 0x7f
+#define __FLT128_MANT_DIG__ 113
+#define __DBL_MAX__ double(1.79769313486231570814527423731704357e+308L)
+#define __FLT32X_DIG__ 15
+#define __WCHAR_MIN__ 0U
+#define __INT64_C(c) c ## L
+#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
+#define __SIZEOF_INT__ 4
+#define __INT_FAST64_WIDTH__ 64
+#define __PRAGMA_REDEFINE_EXTNAME 1
+#define __FLT32X_MANT_DIG__ 53
+#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
+#define __USER_LABEL_PREFIX__ 
+#define __FLT32_MAX_10_EXP__ 38
+#define __FLT64X_EPSILON__ 1.92592994438723585305597794258492732e-34F64x
+#define __STDC_HOSTED__ 1
+#define __cpp_decltype_auto 201304L
+#define __DBL_DIG__ 15
+#define __FLT32_DIG__ 6
+#define __FLT_EPSILON__ 1.19209289550781250000000000000000000e-7F
+#define __GXX_WEAK__ 1
+#define __SHRT_WIDTH__ 16
+#define __FLT32_IS_IEC_60559__ 2
+#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+#define __FLT16_HAS_QUIET_NAN__ 1
+#define __cpp_threadsafe_static_init 200806L
+#define __ARM_SIZEOF_MINIMAL_ENUM 4
+#define __FLT64X_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F64x
+#define __FP_FAST_FMA 1
+#define __FLT32X_HAS_INFINITY__ 1
+#define __INT32_MAX__ 0x7fffffff
+#define __FLT16_DIG__ 3
+#define __INT_WIDTH__ 32
+#define __SIZEOF_LONG__ 8
+#define __STDC_IEC_559__ 1
+#define __UINT16_C(c) c
+#define __DECIMAL_DIG__ 36
+#define __STDC_IEC_559_COMPLEX__ 1
+#define __FLT64_EPSILON__ 2.22044604925031308084726333618164062e-16F64
+#define __gnu_linux__ 1
+#define __INT16_MAX__ 0x7fff
+#define __FLT64_MIN_EXP__ (-1021)
+#define __FLT64X_MIN_10_EXP__ (-4931)
+#define __LDBL_HAS_QUIET_NAN__ 1
+#define __FLT16_MIN_EXP__ (-13)
+#define __FLT64_MANT_DIG__ 53
+#define __FLT64X_MANT_DIG__ 113
+#define __GNUC__ 11
+#define __pie__ 2
+#define __GXX_RTTI 1
+#define __FLT_HAS_DENORM__ 1
+#define __SIZEOF_LONG_DOUBLE__ 16
+#define __cpp_rtti 199711L
+#define __LDBL_MIN_EXP__ (-16381)
+#define __STDC_UTF_16__ 1
+#define __FLT64_MAX_10_EXP__ 308
+#define __FLT16_MAX_10_EXP__ 4
+#define __DBL_IS_IEC_60559__ 2
+#define __FLT32_HAS_INFINITY__ 1
+#define __cpp_raw_strings 200710L
+#define __INT_FAST32_MAX__ 0x7fffffffffffffffL
+#define __DBL_HAS_INFINITY__ 1
+#define __HAVE_SPECULATION_SAFE_VALUE 1
+#define __INTPTR_WIDTH__ 64
+#define __cpp_delegating_constructors 200604L
+#define __FLT32X_HAS_DENORM__ 1
+#define __INT_FAST16_TYPE__ long int
+#define __LDBL_HAS_DENORM__ 1
+#define __cplusplus 201402L
+#define __cpp_ref_qualifiers 200710L
+#define __FLT32_DECIMAL_DIG__ 9
+#define __DEPRECATED 1
+#define __cpp_rvalue_references 200610L
+#define __DBL_MAX_EXP__ 1024
+#define __WCHAR_WIDTH__ 32
+#define __FLT64_MAX__ 1.79769313486231570814527423731704357e+308F64
+#define __FLT32_MAX__ 3.40282346638528859811704183484516925e+38F32
+#define __GCC_ATOMIC_LONG_LOCK_FREE 2
+#define __FLT16_DECIMAL_DIG__ 5
+#define __FLT16_MANT_DIG__ 11
+#define __FLT_IS_IEC_60559__ 2
+#define __FLT32_HAS_QUIET_NAN__ 1
+#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL
+#define __SIZEOF_SIZE_T__ 8
+#define __SIG_ATOMIC_WIDTH__ 32
+#define __ARM_ALIGN_MAX_PWR 28
+#define __SIZEOF_WINT_T__ 4
+#define __LONG_LONG_WIDTH__ 64
+#define __cpp_initializer_lists 200806L
+#define __FLT32_MAX_EXP__ 128
+#define __cpp_hex_float 201603L
+#define __ARM_FP16_FORMAT_IEEE 1
+#define __FLT128_HAS_INFINITY__ 1
+#define __FLT_MIN_EXP__ (-125)
+#define __FLT64_NORM_MAX__ 1.79769313486231570814527423731704357e+308F64
+#define __PIE__ 2
+#define __GCC_HAVE_DWARF2_CFI_ASM 1
+#define __cpp_lambdas 200907L
+#define __FLT32X_MIN_EXP__ (-1021)
+#define __INT_FAST64_TYPE__ long int
+#define __ARM_FP16_ARGS 1
+#define __FP_FAST_FMAF 1
+#define __FLT128_NORM_MAX__ 1.18973149535723176508575932662800702e+4932F128
+#define __FLT64_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F64
+#define __DBL_MIN__ double(2.22507385850720138309023271733240406e-308L)
+#define __ARM_FEATURE_CLZ 1
+#define __FLT16_DENORM_MIN__ 5.96046447753906250000000000000000000e-8F16
+#define __unix__ 1
+#define __FLT64X_NORM_MAX__ 1.18973149535723176508575932662800702e+4932F64x
+#define __SIZEOF_POINTER__ 8
+#define __LP64__ 1
+#define __DBL_HAS_QUIET_NAN__ 1
+#define __FLT_EVAL_METHOD_C99__ 0
+#define __FLT32X_EPSILON__ 2.22044604925031308084726333618164062e-16F32x
+#define __UINT64_MAX__ 0xffffffffffffffffUL
+#define __LDBL_DECIMAL_DIG__ 36
+#define __FLT_MAX__ 3.40282346638528859811704183484516925e+38F
+#define __aarch64__ 1
+#define __FLT64_MIN_10_EXP__ (-307)
+#define __FLT64X_DECIMAL_DIG__ 36
+#define __REGISTER_PREFIX__ 
+#define __UINT16_MAX__ 0xffff
+#define __INTMAX_WIDTH__ 64
+#define __LDBL_HAS_INFINITY__ 1
+#define __FLT_DIG__ 6
+#define __NO_INLINE__ 1
+#define __DEC_EVAL_METHOD__ 2
+#define __FLT_MANT_DIG__ 24
+#define __FLT16_MIN_10_EXP__ (-4)
+#define __VERSION__ "11.4.0"
+#define __UINT64_C(c) c ## UL
+#define __cpp_unicode_characters 200704L
+#define __FLT128_IS_IEC_60559__ 2
+#define __GXX_ABI_VERSION 1016
+#define __WINT_MAX__ 0xffffffffU
+#define __INT_LEAST32_MAX__ 0x7fffffff
+#define __GCC_ATOMIC_INT_LOCK_FREE 2
+#define __FLT32X_MIN__ 2.22507385850720138309023271733240406e-308F32x
+#define __FLT128_MAX_EXP__ 16384
+#define __FLT32_MANT_DIG__ 24
+#define __AARCH64EL__ 1
+#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
+#define __FLT16_MAX_EXP__ 16
+#define __BIGGEST_ALIGNMENT__ 16
+#define __STDC_IEC_60559_COMPLEX__ 201404L
+#define __INT32_C(c) c
+#define __FLT128_HAS_DENORM__ 1
+#define __SCHAR_WIDTH__ 8
+#define __ORDER_PDP_ENDIAN__ 3412
+#define __ARM_64BIT_STATE 1
+#define __INT_FAST32_TYPE__ long int
+#define __UINT_LEAST16_TYPE__ short unsigned int
+#define __SIZE_TYPE__ long unsigned int
+#define __GNUC_WIDE_EXECUTION_CHARSET_NAME "UTF-32LE"
+#define __FLT64X_DIG__ 33
+#define __ARM_FEATURE_FMA 1
+#define __INT8_TYPE__ signed char
+#define __GNUG__ 11
+#define __cpp_digit_separators 201309L
+#define __ELF__ 1
+#define __GCC_ASM_FLAG_OUTPUTS__ 1
+#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
+#define __FLT_RADIX__ 2
+#define __INT_LEAST16_TYPE__ short int
+#define __ARM_ARCH_PROFILE 65
+#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
+#define __UINTMAX_C(c) c ## UL
+#define __GLIBCXX_BITSIZE_INT_N_0 128
+#define __ARM_PCS_AAPCS64 1
+#define __SIG_ATOMIC_MAX__ 0x7fffffff
+#define __INT_LEAST64_WIDTH__ 64
+#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+#define __STDC_IEC_60559_BFP__ 201404L
+#define __SIZEOF_PTRDIFF_T__ 8
+#define __ATOMIC_RELAXED 0
+#define __FLT_EVAL_METHOD_TS_18661_3__ 0
+#define __LDBL_DIG__ 33
+#define __FLT64_IS_IEC_60559__ 2
+#define __FLT16_IS_IEC_60559__ 2
+#define __INT_FAST16_MAX__ 0x7fffffffffffffffL
+#define __FLT64_DIG__ 15
+#define __UINT_FAST32_MAX__ 0xffffffffffffffffUL
+#define __UINT_LEAST64_TYPE__ long unsigned int
+#define __FLT16_EPSILON__ 9.76562500000000000000000000000000000e-4F16
+#define __FLT_HAS_QUIET_NAN__ 1
+#define __FLT_MAX_10_EXP__ 38
+#define __LONG_MAX__ 0x7fffffffffffffffL
+#define __FLT64X_HAS_DENORM__ 1
+#define __FLT_HAS_INFINITY__ 1
+#define __GNUC_EXECUTION_CHARSET_NAME "UTF-8"
+#define __unix 1
+#define __cpp_unicode_literals 200710L
+#define __DBL_HAS_DENORM__ 1
+#define __UINT_FAST16_TYPE__ long unsigned int
+#define __FLT32X_HAS_QUIET_NAN__ 1
+#define __CHAR16_TYPE__ short unsigned int
+#define __FLT64X_MAX_EXP__ 16384
+#define __SIZE_WIDTH__ 64
+#define __INT_LEAST16_MAX__ 0x7fff
+#define __FLT16_NORM_MAX__ 6.55040000000000000000000000000000000e+4F16
+#define __INT64_MAX__ 0x7fffffffffffffffL
+#define __FLT32_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F32
+#define __INT_LEAST64_TYPE__ long int
+#define __INT16_TYPE__ short int
+#define __INT_LEAST8_TYPE__ signed char
+#define __FLT16_MAX__ 6.55040000000000000000000000000000000e+4F16
+#define __INT_FAST8_MAX__ 0x7f
+#define __ARM_ARCH 8
+#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932F128
+#define __INTPTR_MAX__ 0x7fffffffffffffffL
+#define __cpp_sized_deallocation 201309L
+#define linux 1
+#define __ARM_FEATURE_UNALIGNED 1
+#define __FLT64_HAS_QUIET_NAN__ 1
+#define __GXX_EXPERIMENTAL_CXX0X__ 1
+#define __FLT64X_MIN_EXP__ (-16381)
+#define __FLT32_MIN_10_EXP__ (-37)
+#define __UINT8_TYPE__ unsigned char
+#define __PTRDIFF_WIDTH__ 64
+#define __FLT64_HAS_INFINITY__ 1
+#define __FLT64X_MAX__ 1.18973149535723176508575932662800702e+4932F64x
+#define __FLT16_HAS_INFINITY__ 1
+#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
+#define __PTRDIFF_MAX__ 0x7fffffffffffffffL
+#define __cpp_return_type_deduction 201304L
+#define __INTPTR_TYPE__ long int
+#define __UINT16_TYPE__ short unsigned int
+#define __WCHAR_TYPE__ unsigned int
+#define __cpp_range_based_for 200907L
+#define __pic__ 2
+#define __UINTPTR_MAX__ 0xffffffffffffffffUL
+#define __ARM_ARCH_8A 1
+#define __cpp_decltype 200707L
+#define __INT_FAST64_MAX__ 0x7fffffffffffffffL
+#define __FLT_NORM_MAX__ 3.40282346638528859811704183484516925e+38F
+#define __UINT_FAST64_TYPE__ long unsigned int
+#define __INT_MAX__ 0x7fffffff
+#define __STDCPP_THREADS__ 1
+#define __INT64_TYPE__ long int
+#define __FLT_MAX_EXP__ 128
+#define __ORDER_BIG_ENDIAN__ 4321
+#define __DBL_MANT_DIG__ 53
+#define __cpp_inheriting_constructors 201511L
+#define __INT_LEAST64_MAX__ 0x7fffffffffffffffL
+#define __FP_FAST_FMAF32 1
+#define __UINT_LEAST32_TYPE__ unsigned int
+#define __SIZEOF_SHORT__ 2
+#define __FLT32_NORM_MAX__ 3.40282346638528859811704183484516925e+38F32
+#define __GCC_ATOMIC_BOOL_LOCK_FREE 2
+#define __WINT_WIDTH__ 32
+#define __FP_FAST_FMAF64 1
+#define __FLT32X_MAX_10_EXP__ 308
+#define __SIZEOF_INT128__ 16
+#define __FLT16_MIN__ 6.10351562500000000000000000000000000e-5F16
+#define __WCHAR_UNSIGNED__ 1
+#define __LDBL_MAX_10_EXP__ 4932
+#define __DBL_EPSILON__ double(2.22044604925031308084726333618164062e-16L)
+#define __FLT32_MIN_EXP__ (-125)
+#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932F128
+#define _LP64 1
+#define __UINT8_C(c) c
+#define __FLT64_MAX_EXP__ 1024
+#define __INT_LEAST32_TYPE__ int
+#define __ARM_NEON 1
+#define __FLT128_HAS_QUIET_NAN__ 1
+#define __INTMAX_MAX__ 0x7fffffffffffffffL
+#define __UINT_FAST8_TYPE__ unsigned char
+#define __INT_FAST8_TYPE__ signed char
+#define __FLT64X_MIN__ 3.36210314311209350626267781732175260e-4932F64x
+#define __GNUC_STDC_INLINE__ 1
+#define __FLT64_HAS_DENORM__ 1
+#define __FLT32_EPSILON__ 1.19209289550781250000000000000000000e-7F32
+#define __FP_FAST_FMAF32x 1
+#define __FLT16_HAS_DENORM__ 1
+#define __STDC_UTF_32__ 1
+#define __INT_FAST8_WIDTH__ 8
+#define __FLT32X_MAX__ 1.79769313486231570814527423731704357e+308F32x
+#define __cpp_alias_templates 200704L
+#define __DBL_NORM_MAX__ double(1.79769313486231570814527423731704357e+308L)
+#define __FLT64X_HAS_INFINITY__ 1
+#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+#define __ARM_ALIGN_MAX_STACK_PWR 16
+#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
+#define __SIZEOF_WCHAR_T__ 4
+#define unix 1
+#define __cpp_runtime_arrays 198712L
+#define __UINT64_TYPE__ long unsigned int
+#define __UINT32_C(c) c ## U
+#define __WINT_MIN__ 0U
+#define __INT8_MAX__ 0x7f
+#define __LONG_WIDTH__ 64
+#define __PIC__ 2
+#define __FLT32X_NORM_MAX__ 1.79769313486231570814527423731704357e+308F32x
+#define __CHAR32_TYPE__ unsigned int
+#define __cpp_constexpr 201304L
+#define __ARM_FEATURE_NUMERIC_MAXMIN 1
+#define __INT32_TYPE__ int
+#define __SIZEOF_DOUBLE__ 8
+#define __cpp_exceptions 199711L
+#define __FLT64_MIN__ 2.22507385850720138309023271733240406e-308F64
+#define __FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F
+#define __INT_LEAST32_WIDTH__ 32
+#define __SIZEOF_FLOAT__ 4
+#define __ATOMIC_CONSUME 1
+#define __GNUC_MINOR__ 4
+#define __GLIBCXX_TYPE_INT_N_0 __int128
+#define __INT_FAST16_WIDTH__ 64
+#define __UINTMAX_MAX__ 0xffffffffffffffffUL
+#define __FLT32X_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F32x
+#define __DBL_MAX_10_EXP__ 308
+#define __INT16_C(c) c
+#define __ARM_ARCH_ISA_A64 1
+#define __STDC__ 1
+#define __PTRDIFF_TYPE__ long int
+#define __FLT32_MIN__ 1.17549435082228750796873653722224568e-38F32
+#define __ATOMIC_SEQ_CST 5
+#define __EXCEPTIONS 1
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1
+#define __UINT32_TYPE__ unsigned int
+#define __FLT32X_MIN_10_EXP__ (-307)
+#define __UINTPTR_TYPE__ long unsigned int
+#define __linux__ 1
+#define __LDBL_MIN_10_EXP__ (-4931)
+#define __cpp_generic_lambdas 201304L
+#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34F128
+#define __SIZEOF_LONG_LONG__ 8
+#define __cpp_user_defined_literals 200809L
+#define __FLT128_DECIMAL_DIG__ 36
+#define __GCC_ATOMIC_LLONG_LOCK_FREE 2
+#define __FLT_DECIMAL_DIG__ 9
+#define __UINT_FAST16_MAX__ 0xffffffffffffffffUL
+#define __LDBL_NORM_MAX__ 1.18973149535723176508575932662800702e+4932L
+#define __FLT_MIN_10_EXP__ (-37)
+#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
+#define __ORDER_LITTLE_ENDIAN__ 1234
+#define __SIZE_MAX__ 0xffffffffffffffffUL
+#define _GNU_SOURCE 1
+#define __UINT_LEAST32_MAX__ 0xffffffffU
+#define __cpp_init_captures 201304L
+#define __ATOMIC_ACQ_REL 4
+#define __ATOMIC_RELEASE 3

+ 60 - 0
src/tool/picview_usbport/myview.cpp

@@ -0,0 +1,60 @@
+#include "myview.h"
+
+
+#define VIEW_CENTER viewport()->rect().center()
+const double PI = 3.1415926535898;
+
+MyView::MyView(QWidget *parent) :
+     QGraphicsView(parent),
+    beishu(1.00000)
+{
+    setDragMode(QGraphicsView::ScrollHandDrag);
+}
+
+void MyView::mousePressEvent(QMouseEvent *event)
+{
+    bottonstatus = true;
+    QGraphicsView::mousePressEvent(event);
+}
+void MyView::mouseMoveEvent(QMouseEvent *event)
+{
+    QGraphicsView::mouseMoveEvent(event);
+}
+void MyView::mouseReleaseEvent(QMouseEvent *event)
+{
+    bottonstatus = false;
+    QGraphicsView::mouseReleaseEvent(event);
+}
+
+// 放大/缩小
+void MyView::wheelEvent(QWheelEvent *event)
+{
+    // 滚轮的滚动量
+    QPoint scrollAmount = event->angleDelta();
+    // 正值表示滚轮远离使用者(放大),负值表示朝向使用者(缩小)
+    scrollAmount.y() > 0 ? zoomIn() : zoomOut();
+}
+
+// 放大
+void MyView::zoomIn()
+{
+    scale(1.1, 1.1);
+    beishu *= 1.1;
+    centerOn(450, 700 - (200 / beishu));
+}
+
+// 缩小
+void MyView::zoomOut()
+{
+    scale(1 / 1.1, 1 / 1.1);
+    beishu /= 1.1;
+    centerOn(450, 700 - (200 / beishu));
+}
+
+void MyView::viewscaleto(double fratio)
+{
+    double fscale = fratio/beishu;
+    scale(fscale,fscale);
+    beishu *= fscale;
+    centerOn(450, 700 - (200 / beishu));
+}

+ 35 - 0
src/tool/picview_usbport/myview.h

@@ -0,0 +1,35 @@
+#ifndef MYVIEW_H
+#define MYVIEW_H
+
+#include <qtimer.h>
+#include <qpainter.h>
+#include <QGraphicsView>
+#include <QWheelEvent>
+#include <QKeyEvent>
+#include <QPoint>
+#include <QPointF>
+#include <QGraphicsItem>
+#include <QKeyEvent>
+
+class MyView : public QGraphicsView
+{
+    Q_OBJECT
+
+public:
+    explicit MyView(QWidget *parent =0);
+    qreal x, y, beishu;
+    void viewscaleto(double fratio);
+protected:
+    void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
+    void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+    void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+    void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+public Q_SLOTS:
+    void zoomIn();  // 放大
+    void zoomOut();  // 缩小
+private:
+    bool bottonstatus = false;
+    QPoint myview_lastMousePos;
+};
+
+#endif // MYVIEW_H

+ 8 - 0
src/tool/picview_usbport/picview.xml

@@ -0,0 +1,8 @@
+<xml>	
+	<node name="picview">
+		<param name="msgname0" value="picfront" />
+		<param name="msgname1" value="picrear" />
+		<param name="msgname2" value="picleft" />
+		<param name="msgname3" value="picright" />
+	</node>
+</xml>

+ 84 - 0
src/tool/picview_usbport/picview_usbport.pro

@@ -0,0 +1,84 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2018-08-27T22:01:38
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = picview
+TEMPLATE = app
+
+CONFIG += c++14
+
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which has been marked as deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+
+#DEFINES += USE_ROBOSDK
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+
+
+
+SOURCES += \
+    ../../driver/driver_camera_ioctl/usb_cam.cpp \
+        main.cpp \
+        mainwindow.cpp \
+    myview.cpp \
+    ../../include/msgtype/rawpic.pb.cc
+
+HEADERS += \
+    ../../driver/driver_camera_ioctl/usb_cam.h \
+        mainwindow.h \
+    myview.h \
+    ../../include/msgtype/rawpic.pb.h
+
+FORMS += \
+        mainwindow.ui
+
+
+contains(QMAKE_HOST.arch, aarch64){
+    DEFINES += arch_agx
+}else{
+    DEFINES += arch_x64
+}
+
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
+
+!include(../../../include/ivprotobuf.pri ) {
+    error( "Couldn't find the ivprotobuf.pri file!" )
+}
+
+!include(../../../include/ivboost.pri ) {
+    error( "Couldn't find the ivboost.pri file!" )
+}
+
+!include(../../../include/ivopencv.pri ) {
+    error( "Couldn't find the ivopencv.pri file!" )
+}
+
+!include(../../../include/ivpcl.pri ) {
+    error( "Couldn't find the ivpcl.pri file!" )
+}
+
+INCLUDEPATH += /home/linaro/opencv3
+
+
+INCLUDEPATH += $$PWD/../../driver/driver_camera_ioctl
+
+
+DEFINES += USE_OPENCV4
+LIBS +=-lpostproc -lswresample -lswscale -lavfilter -lavdevice -lavformat -lavcodec -lavutil -lm -ldl