16 Commits

Author SHA1 Message Date
AiYangSky
f9c32a3754 Fixed a bug caused by abnormal timestamps in the ROS environment
Signed-off-by: AiYangSky <1732570904@qq.com>
2024-04-11 07:52:39 +00:00
jario
4a9adf7f98 fix Eigen/Dense: No such file err 2024-04-02 12:02:12 +08:00
jario
97ae2aa6c2 fix byte error 2024-04-02 11:50:15 +08:00
jario-jin
a1262883c5 !37 fix bugs in x86-intel.
Merge pull request !37 from Daniel/lxm
2024-02-29 08:16:33 +00:00
Daniel
29a2d9abf5 fix bugs in x86-intel. 2024-02-21 10:08:57 +08:00
Daniel
21cabc3ed7 fix bugs in x86-intel. 2024-02-21 10:04:56 +08:00
jario
f346ad49d9 fix model_sync 2024-02-02 23:26:16 +08:00
jario
29702bfd11 fix camera cannot open continuously 2024-02-02 23:16:49 +08:00
jario
b52645c3a6 fix 2024-01-27 11:07:42 +08:00
jario
83bf2f9656 fix model sync 2024-01-19 23:56:05 +08:00
jario
9c4d8a400c fix 2024-01-19 22:55:31 +08:00
jario
212c9f18fa fix model manager with various batchsize 2024-01-19 21:12:13 +08:00
jario
334c2055d9 fix 2024-01-17 11:35:41 +08:00
jario-jin
5108de8df4 model manager v1.0 & add model_sync.py 2024-01-17 11:00:54 +08:00
jario-jin
62708c742c !36 model-manager-v1
Merge pull request !36 from jario-jin/model-manager
2024-01-12 14:06:24 +00:00
jario-jin
a2621bf4dd fix Intel platform installation script 2024-01-12 22:03:05 +08:00
27 changed files with 265 additions and 60 deletions

View File

@@ -364,12 +364,14 @@ if(PLATFORM STREQUAL "JETSON")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/build/${PROJECT_NAME}Config.cmake.in [[
@PACKAGE_INIT@
find_package(OpenCV 4 REQUIRED)
find_package(Eigen3 REQUIRED)
link_directories(/usr/local/cuda/lib64)
set(SV_INCLUDE_DIRS
@SV_INSTALL_PREFIX@/include
/usr/include/x86_64-linux-gnu
/usr/local/cuda/include
${OpenCV_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
/usr/include/gstreamer-1.0
/usr/local/include/gstreamer-1.0
/usr/include/glib-2.0
@@ -388,6 +390,7 @@ elseif(PLATFORM STREQUAL "X86_CUDA")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/build/${PROJECT_NAME}Config.cmake.in [[
@PACKAGE_INIT@
find_package(OpenCV 4 REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(fmt REQUIRED)
link_directories(/usr/local/cuda/lib64)
set(SV_INCLUDE_DIRS
@@ -395,6 +398,7 @@ set(SV_INCLUDE_DIRS
/usr/include/x86_64-linux-gnu
/usr/local/cuda/include
${OpenCV_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
)
set(SV_LIBRARIES
@SV_INSTALL_PREFIX@/lib/libsv_yoloplugins.so
@@ -409,11 +413,13 @@ elseif(PLATFORM STREQUAL "X86_INTEL")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/build/${PROJECT_NAME}Config.cmake.in [[
@PACKAGE_INIT@
find_package(OpenCV 4 REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(fmt REQUIRED)
set(SV_INCLUDE_DIRS
@SV_INSTALL_PREFIX@/include
/usr/include/x86_64-linux-gnu
${OpenCV_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
)
set(SV_LIBRARIES
@SV_INSTALL_PREFIX@/lib/libsv_world.so

View File

@@ -1,6 +1,7 @@
#include "common_det_cuda_impl.h"
#include <cmath>
#include <fstream>
#include <iostream>
#include "sv_util.h"
#define SV_MODEL_DIR "/SpireCV/models/"
@@ -363,10 +364,16 @@ bool CommonObjectDetectorCUDAImpl::cudaSetup(CommonObjectDetectorBase* base_, bo
bool with_segmentation = base_->withSegmentation();
double thrs_conf = base_->getThrsConf();
double thrs_nms = base_->getThrsNms();
std::string model = base_->getModel();
int bs = base_->getBatchSize();
char bs_c[8];
sprintf(bs_c, "%d", bs);
std::string bs_s(bs_c);
std::string engine_fn = get_home() + SV_MODEL_DIR + dataset + ".engine";
std::vector<std::string> files;
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", dataset + "-yolov5s-");
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-" + dataset + "-yolov5" + model + "_b" + bs_s + "_c");
if (files.size() > 0)
{
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
@@ -376,7 +383,7 @@ bool CommonObjectDetectorCUDAImpl::cudaSetup(CommonObjectDetectorBase* base_, bo
if (input_w == 1280)
{
files.clear();
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", dataset + "-yolov5s6-");
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-" + dataset + "-yolov5" + model + "6_b" + bs_s + "_c");
if (files.size() > 0)
{
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
@@ -392,7 +399,7 @@ bool CommonObjectDetectorCUDAImpl::cudaSetup(CommonObjectDetectorBase* base_, bo
base_->setInputH(640);
base_->setInputW(640);
files.clear();
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", dataset + "-yolov5s-seg-");
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-" + dataset + "-yolov5" + model + "_seg_b" + bs_s + "_c");
if (files.size() > 0)
{
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
@@ -443,17 +450,5 @@ bool CommonObjectDetectorCUDAImpl::cudaSetup(CommonObjectDetectorBase* base_, bo
return false;
}
}

View File

@@ -1,6 +1,7 @@
#include "common_det_intel_impl.h"
#include <cmath>
#include <fstream>
#include "sv_util.h"
#define SV_MODEL_DIR "/SpireCV/models/"
#define SV_ROOT_DIR "/SpireCV/"
@@ -124,17 +125,46 @@ namespace sv
inpHeight = base_->getInputH();
inpWidth = base_->getInputW();
with_segmentation = base_->withSegmentation();
std::string model = base_->getModel();
std::string openvino_fn = get_home() + SV_MODEL_DIR + dataset + ".onnx";
std::vector<std::string> files;
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.onnx", "Int-" + dataset + "-yolov5" + model + "_c");
if (files.size() > 0)
{
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
openvino_fn = get_home() + SV_MODEL_DIR + files[0];
}
if (inpWidth == 1280)
{
openvino_fn = get_home() + SV_MODEL_DIR + dataset + "_HD.onnx";
files.clear();
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.onnx", "Int-" + dataset + "-yolov5" + model + "6_c");
if (files.size() > 0)
{
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
openvino_fn = get_home() + SV_MODEL_DIR + files[0];
}
else
{
openvino_fn = get_home() + SV_MODEL_DIR + dataset + "_HD.onnx";
}
}
if (with_segmentation)
{
base_->setInputH(640);
base_->setInputW(640);
openvino_fn = get_home() + SV_MODEL_DIR + dataset + "_SEG.onnx";
files.clear();
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.onnx", "Int-" + dataset + "-yolov5" + model + "_seg_c");
if (files.size() > 0)
{
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
openvino_fn = get_home() + SV_MODEL_DIR + files[0];
}
else
{
openvino_fn = get_home() + SV_MODEL_DIR + dataset + "_SEG.onnx";
}
}
std::cout << "Load: " << openvino_fn << std::endl;
if (!is_file_exist(openvino_fn))

View File

@@ -53,7 +53,7 @@ bool LandingMarkerDetectorCUDAImpl::cudaSetup()
std::string trt_model_fn = get_home() + SV_MODEL_DIR + "LandingMarker.engine";
std::vector<std::string> files;
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "LandingMarker-");
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-LandingMarker-resnet34");
if (files.size() > 0)
{
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);

View File

@@ -1,6 +1,7 @@
#include "landing_det_intel_impl.h"
#include <cmath>
#include <fstream>
#include "sv_util.h"
#define SV_MODEL_DIR "/SpireCV/models/"
#define SV_ROOT_DIR "/SpireCV/"
@@ -26,6 +27,14 @@ namespace sv
{
#ifdef WITH_INTEL
std::string onnx_model_fn = get_home() + SV_MODEL_DIR + "LandingMarker.onnx";
std::vector<std::string> files;
list_dir(get_home() + SV_MODEL_DIR, files, "-online.onnx", "Int-LandingMarker-resnet34");
if (files.size() > 0)
{
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
onnx_model_fn = get_home() + SV_MODEL_DIR + files[0];
}
if (!is_file_exist(onnx_model_fn))
{
throw std::runtime_error("SpireCV (104) Error loading the LandingMarker ONNX model (File Not Exist)");

View File

@@ -33,9 +33,9 @@ bool SingleObjectTrackerOCV470Impl::ocv470Setup(SingleObjectTrackerBase* base_)
std::string kernel_r1 = get_home() + SV_MODEL_DIR + "dasiamrpn_kernel_r1.onnx";
std::vector<std::string> files1, files2, files3;
_list_dir(get_home() + SV_MODEL_DIR, files1, "-online.engine", "DaSiamRPN-Model-");
_list_dir(get_home() + SV_MODEL_DIR, files2, "-online.engine", "DaSiamRPN-Kernel-CLS1-");
_list_dir(get_home() + SV_MODEL_DIR, files3, "-online.engine", "DaSiamRPN-Kernel-R1-");
_list_dir(get_home() + SV_MODEL_DIR, files1, ".onnx", "Ocv-DaSiamRPN-Model-");
_list_dir(get_home() + SV_MODEL_DIR, files2, ".onnx", "Ocv-DaSiamRPN-Kernel-CLS1-");
_list_dir(get_home() + SV_MODEL_DIR, files3, ".onnx", "Ocv-DaSiamRPN-Kernel-R1-");
if (files1.size() > 0 && files2.size() > 0 && files3.size() > 0)
{
std::sort(files1.rbegin(), files1.rend(), _comp_str_lesser);
@@ -53,8 +53,8 @@ bool SingleObjectTrackerOCV470Impl::ocv470Setup(SingleObjectTrackerBase* base_)
std::string neckhead = get_home() + SV_MODEL_DIR + "nanotrack_head_sim.onnx";
std::vector<std::string> files4, files5;
_list_dir(get_home() + SV_MODEL_DIR, files4, "-online.engine", "NanoTrack-Backbone-SIM-");
_list_dir(get_home() + SV_MODEL_DIR, files5, "-online.engine", "NanoTrack-Head-SIM-");
_list_dir(get_home() + SV_MODEL_DIR, files4, ".onnx", "Ocv-NanoTrack-Backbone-SIM-");
_list_dir(get_home() + SV_MODEL_DIR, files5, ".onnx", "Ocv-NanoTrack-Head-SIM-");
if (files4.size() > 0 && files5.size() > 0)
{
std::sort(files4.rbegin(), files4.rend(), _comp_str_lesser);

View File

@@ -32,7 +32,7 @@ CameraAlgorithm::CameraAlgorithm()
// this->_allocator = NULL;
this->_t0 = std::chrono::system_clock::now();
this->alg_params_fn = _get_home() + SV_ROOT_DIR + "params/a-params/sv_algorithm_params.json";
this->alg_params_fn = _get_home() + SV_ROOT_DIR + "confs/sv_algorithm_params.json";
// std::cout << "CameraAlgorithm->alg_params_fn: " << this->alg_params_fn << std::endl;
// if (_is_file_exist(params_fn))
// this->loadAlgorithmParams(params_fn);
@@ -916,6 +916,14 @@ void CommonObjectDetectorBase::setInputW(int w_)
{
this->_input_w = w_;
}
std::string CommonObjectDetectorBase::getModel()
{
return this->_model;
}
int CommonObjectDetectorBase::getBatchSize()
{
return this->_batch_size;
}
void CommonObjectDetectorBase::warmUp()
{
@@ -1082,6 +1090,8 @@ void CommonObjectDetectorBase::_load()
this->_thrs_nms = 0.6;
this->_thrs_conf = 0.4;
this->_use_width_or_height = 0;
this->_batch_size = 1;
this->_model = "s";
for (auto i : detector_params_value) {
@@ -1089,6 +1099,12 @@ void CommonObjectDetectorBase::_load()
this->_dataset = i->value.toString();
std::cout << "dataset: " << this->_dataset << std::endl;
}
else if ("batchSize" == std::string(i->key)) {
this->_batch_size = i->value.toNumber();
}
else if ("model" == std::string(i->key)) {
this->_model = i->value.toString();
}
else if ("inputSize" == std::string(i->key)) {
// std::cout << "inputSize (old, new): " << this->_input_w << ", " << i->value.toNumber() << std::endl;
this->_input_w = i->value.toNumber();

View File

@@ -78,7 +78,7 @@ namespace sv
std::string trt_model_fn = get_home() + SV_MODEL_DIR + "veri.engine";
std::vector<std::string> files;
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "VERI-");
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-VERI-mobilenet_v3");
if (files.size() > 0)
{
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);

View File

@@ -28,6 +28,7 @@ GX40GimbalDriver::GX40GimbalDriver(amovGimbal::IOStreamBase *_IO) : amovGimbal::
targetPos[2] = 0;
parserState = GX40::GIMBAL_FRAME_PARSER_STATE_IDLE;
upDataTs = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()) - std::chrono::milliseconds(2000);
}
/**
@@ -107,7 +108,8 @@ uint32_t GX40GimbalDriver::pack(IN uint32_t cmd, uint8_t *pPayload, uint8_t payl
// 惯导数据填充
std::chrono::milliseconds nowTs = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
// over 1s GNSS has losed
if ((nowTs.count() - upDataTs.count()) < std::chrono::milliseconds(1500).count())
if ((nowTs.count() - upDataTs.count()) < std::chrono::milliseconds(1500).count() &&
cmd == GX40::GIMBAL_CMD_NOP)
{
primary->selfRoll = (int16_t)(-(carrierPos.roll / 0.01f));
primary->selfPitch = (int16_t)(-(carrierPos.pitch / 0.01f));

View File

@@ -140,6 +140,8 @@ public:
double getThrsConf();
int useWidthOrHeight();
bool withSegmentation();
std::string getModel();
int getBatchSize();
protected:
virtual bool setupImpl();
virtual void detectImpl(
@@ -166,6 +168,8 @@ protected:
double _thrs_conf;
int _use_width_or_height;
bool _with_segmentation;
std::string _model;
int _batch_size;
};

View File

@@ -8,8 +8,8 @@
#include <opencv2/tracking.hpp>
#include <string>
#include <chrono>
#include <Eigen/Dense>
//#include <Eigen/Dense>
#include <eigen3/Eigen/Dense>
namespace sv {

View File

@@ -1,11 +1,13 @@
{
"CommonObjectDetector": {
"dataset": "COCO",
"model": "s",
"batchSize": 1,
"inputSize": 640,
"withSegmentation": true,
"nmsThrs": 0.6,
"scoreThrs": 0.4,
"useWidthOrHeight": 1,
"withSegmentation": true,
"datasetPersonVehicle": {
"person": [0.5, 1.8],
"car": [4.1, 1.5],

View File

@@ -1,11 +1,13 @@
{
"CommonObjectDetector": {
"dataset": "COCO",
"model": "s",
"batchSize": 1,
"inputSize": 1280,
"withSegmentation": false,
"nmsThrs": 0.6,
"scoreThrs": 0.4,
"useWidthOrHeight": 1,
"withSegmentation": false,
"datasetPersonVehicle": {
"person": [0.5, 1.8],
"car": [4.1, 1.5],

View File

@@ -1,11 +1,13 @@
{
"CommonObjectDetector": {
"dataset": "COCO",
"model": "s",
"batchSize": 1,
"inputSize": 640,
"withSegmentation": true,
"nmsThrs": 0.6,
"scoreThrs": 0.4,
"useWidthOrHeight": 1,
"withSegmentation": true,
"datasetPersonVehicle": {
"person": [0.5, 1.8],
"car": [4.1, 1.5],

View File

@@ -1,11 +1,13 @@
{
"CommonObjectDetector": {
"dataset": "COCO",
"model": "s",
"batchSize": 1,
"inputSize": 640,
"withSegmentation": false,
"nmsThrs": 0.6,
"scoreThrs": 0.4,
"useWidthOrHeight": 1,
"withSegmentation": false,
"datasetPersonVehicle": {
"person": [0.5, 1.8],
"car": [4.1, 1.5],

View File

@@ -1,11 +1,13 @@
{
"CommonObjectDetector": {
"dataset": "COCO",
"model": "s",
"batchSize": 1,
"inputSize": 1280,
"withSegmentation": false,
"nmsThrs": 0.6,
"scoreThrs": 0.4,
"useWidthOrHeight": 1,
"withSegmentation": false,
"datasetPersonVehicle": {
"person": [0.5, 1.8],
"car": [4.1, 1.5],

View File

@@ -1,11 +1,13 @@
{
"CommonObjectDetector": {
"dataset": "COCO",
"model": "s",
"batchSize": 1,
"inputSize": 640,
"withSegmentation": false,
"nmsThrs": 0.6,
"scoreThrs": 0.4,
"useWidthOrHeight": 1,
"withSegmentation": true,
"datasetPersonVehicle": {
"person": [0.5, 1.8],
"car": [4.1, 1.5],

View File

@@ -1,11 +1,13 @@
{
"CommonObjectDetector": {
"dataset": "COCO",
"model": "s",
"batchSize": 1,
"inputSize": 640,
"withSegmentation": true,
"nmsThrs": 0.6,
"scoreThrs": 0.4,
"useWidthOrHeight": 1,
"withSegmentation": true,
"datasetPersonVehicle": {
"person": [0.5, 1.8],
"car": [4.1, 1.5],

View File

@@ -1,11 +1,13 @@
{
"CommonObjectDetector": {
"dataset": "COCO",
"model": "s",
"batchSize": 1,
"inputSize": 640,
"withSegmentation": true,
"nmsThrs": 0.6,
"scoreThrs": 0.4,
"useWidthOrHeight": 1,
"withSegmentation": true,
"datasetPersonVehicle": {
"person": [0.5, 1.8],
"car": [4.1, 1.5],

View File

@@ -1,11 +1,13 @@
{
"CommonObjectDetector": {
"dataset": "COCO",
"model": "s",
"batchSize": 1,
"inputSize": 640,
"withSegmentation": true,
"nmsThrs": 0.6,
"scoreThrs": 0.4,
"useWidthOrHeight": 1,
"withSegmentation": true,
"datasetPersonVehicle": {
"person": [0.5, 1.8],
"car": [4.1, 1.5],

View File

@@ -1,11 +1,13 @@
{
"CommonObjectDetector": {
"dataset": "COCO",
"model": "s",
"batchSize": 1,
"inputSize": 640,
"withSegmentation": true,
"nmsThrs": 0.6,
"scoreThrs": 0.4,
"useWidthOrHeight": 1,
"withSegmentation": true,
"datasetPersonVehicle": {
"person": [0.5, 1.8],
"car": [4.1, 1.5],

View File

@@ -5,7 +5,7 @@
#include <stdio.h>
#define SERV_PORT 20166
typedef unsigned char byte;
using namespace std;
@@ -23,9 +23,9 @@ int main(int argc, char *argv[]) {
int upd_msg_len = 1024 * 6; // max_objects = 100
byte upd_msg[upd_msg_len];
unsigned char upd_msg[upd_msg_len];
int msg_queue_len = 1024 * 1024; // 1M
byte msg_queue[msg_queue_len];
unsigned char msg_queue[msg_queue_len];
int addr_len = sizeof(struct sockaddr_in);
int start_index = 0, end_index = 0;
@@ -63,21 +63,21 @@ cout << n << ", " << start_index << ", " << end_index << endl;
if (end_index - i >= ilen + 2 && msg_queue[i+ilen] == 0xFB && msg_queue[i+ilen+1] == 0xFD)
{
cout << "FOUND 0xFAFC & 0xFBFD" << endl;
byte* msg_type = reinterpret_cast<byte*>(&msg_queue[i+2]);
unsigned char* msg_type = reinterpret_cast<unsigned char*>(&msg_queue[i+2]);
cout << "Type: " << (int) *msg_type << endl;
unsigned short* year = reinterpret_cast<unsigned short*>(&msg_queue[i+7]);
byte* month = reinterpret_cast<byte*>(&msg_queue[i+9]);
byte* day = reinterpret_cast<byte*>(&msg_queue[i+10]);
byte* hour = reinterpret_cast<byte*>(&msg_queue[i+11]);
byte* minute = reinterpret_cast<byte*>(&msg_queue[i+12]);
byte* second = reinterpret_cast<byte*>(&msg_queue[i+13]);
unsigned char* month = reinterpret_cast<unsigned char*>(&msg_queue[i+9]);
unsigned char* day = reinterpret_cast<unsigned char*>(&msg_queue[i+10]);
unsigned char* hour = reinterpret_cast<unsigned char*>(&msg_queue[i+11]);
unsigned char* minute = reinterpret_cast<unsigned char*>(&msg_queue[i+12]);
unsigned char* second = reinterpret_cast<unsigned char*>(&msg_queue[i+13]);
unsigned short* millisecond = reinterpret_cast<unsigned short*>(&msg_queue[i+14]);
cout << "Time: " << *year << "-" << (int) *month << "-" << (int) *day << " " << (int) *hour << ":" << (int) *minute << ":" << (int) *second << " " << *millisecond << endl;
byte* index_d1 = reinterpret_cast<byte*>(&msg_queue[i+16]);
byte* index_d2 = reinterpret_cast<byte*>(&msg_queue[i+17]);
byte* index_d3 = reinterpret_cast<byte*>(&msg_queue[i+18]);
byte* index_d4 = reinterpret_cast<byte*>(&msg_queue[i+19]);
unsigned char* index_d1 = reinterpret_cast<unsigned char*>(&msg_queue[i+16]);
unsigned char* index_d2 = reinterpret_cast<unsigned char*>(&msg_queue[i+17]);
unsigned char* index_d3 = reinterpret_cast<unsigned char*>(&msg_queue[i+18]);
unsigned char* index_d4 = reinterpret_cast<unsigned char*>(&msg_queue[i+19]);
int mp = i+20;
if ((*index_d4) & 0x01 == 0x01)
{
@@ -152,13 +152,13 @@ cout << n << ", " << start_index << ", " << end_index << endl;
}
for (int j=0; j<n_objects; j++)
{
byte* index_f1 = reinterpret_cast<byte*>(&msg_queue[mp]);
unsigned char* index_f1 = reinterpret_cast<unsigned char*>(&msg_queue[mp]);
mp++;
byte* index_f2 = reinterpret_cast<byte*>(&msg_queue[mp]);
unsigned char* index_f2 = reinterpret_cast<unsigned char*>(&msg_queue[mp]);
mp++;
byte* index_f3 = reinterpret_cast<byte*>(&msg_queue[mp]);
unsigned char* index_f3 = reinterpret_cast<unsigned char*>(&msg_queue[mp]);
mp++;
byte* index_f4 = reinterpret_cast<byte*>(&msg_queue[mp]);
unsigned char* index_f4 = reinterpret_cast<unsigned char*>(&msg_queue[mp]);
mp++;
if ((*index_f4) & 0x01 == 0x01 && (*index_f4) & 0x02 == 0x02)
{

119
scripts/model_sync.py Normal file
View File

@@ -0,0 +1,119 @@
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import os
import requests
import argparse
root_url = "https://download.amovlab.com/model/SpireCV-models/"
model_list_url = root_url + "model-list.txt"
root_path = os.path.expanduser("~") + "/SpireCV/models"
print("MODEL PATH:", root_path)
if not os.path.exists(root_path):
os.makedirs(root_path)
list_file = os.path.join(root_path, "model-list.txt")
def main():
parser = argparse.ArgumentParser(description="SpireCV Model SYNC")
parser.add_argument(
"-p", "--platform",
type=str,
required=True,
help="Supported Platforms: nv (Nvidia), int (Intel)",
)
args = parser.parse_args()
if args.platform in ['nv', 'nvidia', 'Nv', 'Nvidia']:
prefix = 'Nv'
elif args.platform in ['int', 'intel', 'Int', 'Intel']:
prefix = 'Int'
else:
raise Exception("Platform NOT Support!")
r = requests.get(model_list_url)
with open(list_file, "wb") as f:
f.write(r.content)
with open(list_file, 'r') as file:
lines = file.readlines()
need_switch = False
for line in lines:
line = line.strip()
if len(line) > 0:
model_file = os.path.join(root_path, line)
if not os.path.exists(model_file) and (line.startswith(prefix) or line.startswith('Ocv')):
print("[1] Downloading Model:", line, "...")
r = requests.get(root_url + line)
with open(model_file, "wb") as f:
f.write(r.content)
need_switch = True
if os.path.exists(model_file):
print("[1] Model:", line, "EXIST!")
if line.startswith('Nv'):
net = line.split('-')[2]
if net.startswith("yolov5"):
if len(net.split('_')) == 3:
name, seg, ncls = net.split('_')
engine_fn = os.path.splitext(model_file)[0].replace(net, name + "_" + seg + '_b1_' + ncls) + '.engine'
online_fn = os.path.splitext(model_file)[0].replace(net, name + "_" + seg + '_b1_' + ncls) + '-online.engine'
else:
name, ncls = net.split('_')
engine_fn = os.path.splitext(model_file)[0].replace(net, name + '_b1_' + ncls) + '.engine'
online_fn = os.path.splitext(model_file)[0].replace(net, name + '_b1_' + ncls) + '-online.engine'
else:
engine_fn = os.path.splitext(model_file)[0] + '.engine'
online_fn = os.path.splitext(model_file)[0] + '-online.engine'
if not os.path.exists(engine_fn) and not os.path.exists(online_fn):
if net.startswith("yolov5"):
if len(net.split('_')) == 3:
name, seg, ncls = net.split('_')
cmd = "SpireCVSeg -s {} {} {} {}".format(
model_file, engine_fn, ncls[1:], name[6:]
)
else:
name, ncls = net.split('_')
cmd = "SpireCVDet -s {} {} {} {}".format(
model_file, engine_fn, ncls[1:], name[6:]
)
elif line.endswith("onnx"):
cmd = ("/usr/src/tensorrt/bin/trtexec --explicitBatch --onnx={} "
"--saveEngine={} --fp16").format(
model_file, engine_fn
)
print(" [2] Converting Model:", line, "->", engine_fn, "...")
result = os.popen(cmd).read()
need_switch = True
else:
print(" [2] Model Converting FINISH!")
model_file = engine_fn
if not line.startswith('Ocv') and need_switch:
ext = os.path.splitext(model_file)[1]
fn_prefix = '-'.join(os.path.basename(model_file).split('-')[:3])
file_names = os.listdir(root_path)
selected = []
for file_name in file_names:
if file_name.startswith(fn_prefix) and file_name.endswith(ext):
selected.append(file_name)
if len(selected) > 0:
for i, sel in enumerate(selected):
if sel.endswith('-online' + ext):
os.rename(
os.path.join(root_path, sel),
os.path.join(root_path, '-'.join(sel.split('-')[:4])) + ext
)
selected[i] = '-'.join(sel.split('-')[:4]) + ext
selected.sort(reverse=True)
os.rename(
os.path.join(root_path, selected[0]),
os.path.join(root_path, os.path.splitext(selected[0])[0] + "-online" + ext)
)
online_model = os.path.splitext(selected[0])[0] + "-online" + ext
print(" [3] Model {} ONLINE *".format(online_model))
if __name__ == "__main__":
main()

View File

@@ -1,6 +1,6 @@
#!/bin/sh
sudo apt install -y v4l-utils
sudo apt install -y v4l-utils build-essential yasm cmake libtool libc6 libc6-dev unzip wget libeigen3-dev libfmt-dev libnuma1 libnuma-dev libx264-dev libx265-dev libfaac-dev libssl-dev v4l-utils
wget https://ffmpeg.org/releases/ffmpeg-4.2.5.tar.bz2
tar -xjf ffmpeg-4.2.5.tar.bz2
cd ffmpeg-4.2.5

View File

@@ -2,5 +2,5 @@
sudo apt-get install -y libmfx1 libmfx-tools libva-dev libmfx-dev intel-media-va-driver-non-free vainfo
echo "export LIBVA_DRIVER_NAME=iHD" >> ~/.bashrc
source ~/.bashrc
export LIBVA_DRIVER_NAME=iHD

View File

@@ -16,5 +16,5 @@ cd /opt/intel
sudo ln -s openvino_2022.3.1 openvino_2022
echo "source /opt/intel/openvino_2022/setupvars.sh" >> ~/.bashrc
source ~/.bashrc
sh /opt/intel/openvino_2022/setupvars.sh
cd ${current_dir}

View File

@@ -1173,6 +1173,7 @@ void CameraBase::openImpl()
}
void CameraBase::open(CameraType type, int id)
{
this->release();
this->_type = type;
this->_camera_id = id;
@@ -1215,7 +1216,7 @@ bool CameraBase::read(cv::Mat& image)
this->_is_updated = false;
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(20));
std::this_thread::sleep_for(std::chrono::milliseconds(2));
n_try ++;
}
}
@@ -1227,7 +1228,10 @@ bool CameraBase::read(cv::Mat& image)
}
void CameraBase::release()
{
_cap.release();
this->_is_running = false;
this->_is_updated = false;
if (this->_cap.isOpened())
this->_cap.release();
}