Browse Source

add adapi_driver_camera for use camera data for c++

yuchuli 5 months ago
parent
commit
e50c035d1f

+ 73 - 0
src/api/adapi_driver_camera/.gitignore

@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 5 - 0
src/api/adapi_driver_camera/Readme.md

@@ -0,0 +1,5 @@
+
+protoc -I=./ --cpp_out=./ rawpic.proto
+
+
+

+ 35 - 0
src/api/adapi_driver_camera/adapi_driver_camera.pro

@@ -0,0 +1,35 @@
+QT -= gui
+
+CONFIG += c++11 console
+CONFIG -= app_bundle
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked 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
+
+# You can also make your code fail to compile if it uses 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 += \
+        main.cpp \
+        rawpic.pb.cc
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+HEADERS += \
+    rawpic.pb.h
+
+
+LIBS += -lprotobuf
+
+LIBS += -L$$PWD -lmodulecomm
+
+unix:INCLUDEPATH += /usr/include/opencv4
+unix:LIBS += -lopencv_highgui -lopencv_core -lopencv_imgproc -lopencv_imgcodecs -lopencv_video -lopencv_videoio -lpthread  #-lopencv_shape

+ 51 - 0
src/api/adapi_driver_camera/main.cpp

@@ -0,0 +1,51 @@
+#include <QCoreApplication>
+
+#include <iostream>
+#include "modulecomm.h"
+#include "rawpic.pb.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>
+
+static void * gpa;
+
+
+static void CallDetect(iv::vision::rawpic & xrawpic)
+{
+    cv::Mat mat(xrawpic.height(),xrawpic.width(),xrawpic.mattype());
+
+    if(xrawpic.type() == 1)
+        memcpy(mat.data,xrawpic.picdata().data(),mat.rows*mat.cols*mat.elemSize());
+    else
+    {
+        std::vector<unsigned char> buff(xrawpic.picdata().data(),xrawpic.picdata().data()+xrawpic.picdata().size());
+        mat = cv::imdecode(buff,1);
+    }
+    cv::cvtColor(mat, mat, CV_BGR2RGB);
+    //Call Detect Funcion use mat
+}
+
+void Listenpic(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+    (void)index; (void)dt;  (void)strmemname;
+    iv::vision::rawpic pic;
+    if(false == pic.ParseFromArray(strdata,nSize))
+    {
+        std::cout<<"picview Listenpic fail."<<std::endl;
+        return;
+    }
+    CallDetect(pic);
+
+}
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication a(argc, argv);
+
+    gpa = iv::modulecomm::RegisterRecv("image00",Listenpic);
+
+    return a.exec();
+}

+ 16 - 0
src/api/adapi_driver_camera/rawpic.proto

@@ -0,0 +1,16 @@
+syntax = "proto2";
+
+package iv.vision;
+
+
+message rawpic
+{
+  optional int64 time = 1; // number of milliseconds since 1970-01-01T00:00:00 Universal Coordinated Time
+  optional int32 index = 2;
+  optional int32 type = 3; //类型, 1 mat 2 jpg
+  optional int32 width = 4;
+  optional int32 height = 5;
+  optional int32 elemsize = 6;
+  optional int32 mattype = 7;
+  optional bytes picdata = 8;
+};

+ 1 - 1
src/api/adapi_driver_lidar/main.cpp

@@ -7,7 +7,6 @@
 
 static void * gpa;
 
-
 void ListenPointCloud(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
 {
     (void)index;(void)dt;(void)strmemname;
@@ -34,6 +33,7 @@ void ListenPointCloud(const char * strdata,const unsigned int nSize,const unsign
     for(i=0;i<nPCount;i++)
     {
         pcl::PointXYZI xp;
+        xp.data_c
 
         memcpy(&xp,p,sizeof(pcl::PointXYZI));
         point_cloud->push_back(xp);