update.
This commit is contained in:
parent
6a818d85ca
commit
33a0c50ea3
1
.vscode/c_cpp_properties.json
vendored
1
.vscode/c_cpp_properties.json
vendored
@ -4,6 +4,7 @@
|
|||||||
"name": "Linux",
|
"name": "Linux",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"${workspaceFolder}/**",
|
"${workspaceFolder}/**",
|
||||||
|
"3rdparty/ds_pedestrian_mot_hisi/include",
|
||||||
"/opt/aarch64-v01c01-linux-gnu-gcc/lib/libdatachannel-0.22.6/include",
|
"/opt/aarch64-v01c01-linux-gnu-gcc/lib/libdatachannel-0.22.6/include",
|
||||||
"/opt/aarch64-v01c01-linux-gnu-gcc/lib/boost_1_88_0/include",
|
"/opt/aarch64-v01c01-linux-gnu-gcc/lib/boost_1_88_0/include",
|
||||||
"/opt/aarch64-v01c01-linux-gnu-gcc/lib/ZLMediaKit/include",
|
"/opt/aarch64-v01c01-linux-gnu-gcc/lib/ZLMediaKit/include",
|
||||||
|
@ -9,6 +9,7 @@ add_executable(PassengerStatistics main.cpp
|
|||||||
ImageUtilities.h ImageUtilities.cpp
|
ImageUtilities.h ImageUtilities.cpp
|
||||||
NngServer.h NngServer.cpp
|
NngServer.h NngServer.cpp
|
||||||
RtspServer.h RtspServer.cpp
|
RtspServer.h RtspServer.cpp
|
||||||
|
RwAlgorithm.h RwAlgorithm.cpp
|
||||||
Settings.h Settings.cpp
|
Settings.h Settings.cpp
|
||||||
VideoInput.h VideoInput.cpp
|
VideoInput.h VideoInput.cpp
|
||||||
|
|
||||||
@ -25,6 +26,8 @@ add_executable(PassengerStatistics main.cpp
|
|||||||
target_include_directories(PassengerStatistics
|
target_include_directories(PassengerStatistics
|
||||||
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/rw_mpp/include
|
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/rw_mpp/include
|
||||||
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/fsan_sensorsdk/include
|
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/fsan_sensorsdk/include
|
||||||
|
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/libsetscene/include
|
||||||
|
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/ds_pedestrian_mot_hisi/include
|
||||||
PRIVATE ${ZLMediaKit_INCLUDE_DIR}
|
PRIVATE ${ZLMediaKit_INCLUDE_DIR}
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
@ -32,6 +35,8 @@ target_include_directories(PassengerStatistics
|
|||||||
target_link_directories(PassengerStatistics
|
target_link_directories(PassengerStatistics
|
||||||
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/rw_mpp/lib
|
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/rw_mpp/lib
|
||||||
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/fsan_sensorsdk/libs
|
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/fsan_sensorsdk/libs
|
||||||
|
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/libsetscene/lib
|
||||||
|
PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/ds_pedestrian_mot_hisi/libs
|
||||||
PRIVATE ${ZLMediaKit_LIBRARY_DIRS}
|
PRIVATE ${ZLMediaKit_LIBRARY_DIRS}
|
||||||
PRIVATE ${OPENSSL_LIBRARY_DIRS}
|
PRIVATE ${OPENSSL_LIBRARY_DIRS}
|
||||||
)
|
)
|
||||||
@ -46,6 +51,8 @@ target_link_libraries(PassengerStatistics
|
|||||||
PRIVATE Boost::json
|
PRIVATE Boost::json
|
||||||
PRIVATE rw_mpp
|
PRIVATE rw_mpp
|
||||||
PRIVATE sensorsdk
|
PRIVATE sensorsdk
|
||||||
|
PRIVATE setscene
|
||||||
|
PRIVATE ds_pedestrian_mot_Hi3516DV500
|
||||||
PRIVATE mk_api
|
PRIVATE mk_api
|
||||||
PRIVATE opencv_world
|
PRIVATE opencv_world
|
||||||
PRIVATE ${SCTP_LIBRARIES}
|
PRIVATE ${SCTP_LIBRARIES}
|
||||||
|
56
Main/RwAlgorithm.cpp
Normal file
56
Main/RwAlgorithm.cpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#include "RwAlgorithm.h"
|
||||||
|
#include "Core/Logger.h"
|
||||||
|
#include <ds_pedestrian_mot_hisi.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
|
bool Algorithm::initialize() {
|
||||||
|
using namespace std::chrono;
|
||||||
|
if (m_firstTime == system_clock::time_point{}) {
|
||||||
|
m_firstTime = system_clock::now();
|
||||||
|
}
|
||||||
|
if (duration_cast<seconds>(system_clock::now() - m_firstTime) < seconds(10)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr auto licensePath = "/kdata/net.lic";
|
||||||
|
bool licenseExisted = std::filesystem::exists(licensePath);
|
||||||
|
if (licenseExisted && std::filesystem::file_size(licensePath) <= 0) {
|
||||||
|
LOG(warning) << "license[" << licensePath << "] content is empty, remove it.";
|
||||||
|
std::filesystem::remove(licensePath);
|
||||||
|
licenseExisted = false;
|
||||||
|
}
|
||||||
|
ds_pedestrian_hisi_set_lic_path("/kdata");
|
||||||
|
int status =
|
||||||
|
ds_pedestrian_hisi_init(&m_handle, "/system/models/ds_mot_m0_2100.bin", "/system/models/ds_mot_m1_2100.bin",
|
||||||
|
DetectImageWidth, DetectImageHeight, 3); // 不知道什么原因,直接崩溃
|
||||||
|
|
||||||
|
if (status != 0) {
|
||||||
|
LOG(error) << "ds_pedestrian_hisi_init() failed, error: " << status;
|
||||||
|
m_handle = NULL;
|
||||||
|
} else {
|
||||||
|
if (!licenseExisted && std::filesystem::exists(licensePath)) {
|
||||||
|
system("sync");
|
||||||
|
}
|
||||||
|
LOG(info) << "algorithm initialize succeeded.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_handle != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Algorithm::detect(const uint8_t *imageData) {
|
||||||
|
if (m_handle == nullptr) {
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
if (m_handle == nullptr) return;
|
||||||
|
NV21ToBGR24(imageData, m_buffer.data(), DetectImageWidth, DetectImageHeight);
|
||||||
|
|
||||||
|
std::vector<PedestrianRect> bboxes;
|
||||||
|
ds_pedestrian_det_hisi(m_handle, m_buffer.data(), bboxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Algorithm::NV21ToBGR24(const unsigned char *nv21Data, unsigned char *bgr24Data, int width, int height) {
|
||||||
|
cv::Mat nv21Image(height + height / 2, width, CV_8UC1, const_cast<unsigned char *>(nv21Data));
|
||||||
|
cv::Mat bgrImage(height, width, CV_8UC3, bgr24Data);
|
||||||
|
cv::cvtColor(nv21Image, bgrImage, cv::COLOR_YUV2BGR_NV21);
|
||||||
|
}
|
24
Main/RwAlgorithm.h
Normal file
24
Main/RwAlgorithm.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef __ALGORITHM_H__
|
||||||
|
#define __ALGORITHM_H__
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
class Algorithm {
|
||||||
|
public:
|
||||||
|
static constexpr int DetectImageWidth = 1024;
|
||||||
|
static constexpr int DetectImageHeight = 576;
|
||||||
|
bool initialize();
|
||||||
|
void detect(const uint8_t *imageData);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void NV21ToBGR24(const unsigned char *nv21Data, unsigned char *bgr24Data, int width, int height);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void *m_handle = nullptr;
|
||||||
|
std::array<uint8_t, DetectImageWidth * DetectImageHeight> m_buffer;
|
||||||
|
std::chrono::system_clock::time_point m_firstTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __ALGORITHM_H__
|
@ -1,5 +1,6 @@
|
|||||||
#include "VideoInput.h"
|
#include "VideoInput.h"
|
||||||
#include "Core/Logger.h"
|
#include "Core/Logger.h"
|
||||||
|
#include "get_scene_param_videomode.h"
|
||||||
#include "rw_mpp_api.h"
|
#include "rw_mpp_api.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
@ -17,12 +18,18 @@ VideoInput::VideoInput(int32_t width, int32_t height) : m_d(new VideoInputPrivat
|
|||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
LOG(error) << "rw_mpp__vdec_init() failed, status: " << status;
|
LOG(error) << "rw_mpp__vdec_init() failed, status: " << status;
|
||||||
}
|
}
|
||||||
|
RWISP_SceneAuto_init(); // 初始化 ISP 库
|
||||||
|
SceneAuto_Cmd command;
|
||||||
|
command.commandID = FaceAE_EN;
|
||||||
|
command.faceFlag = 0x01;
|
||||||
|
RWISP_SetSceneAuto(&command);
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoInput::~VideoInput() {
|
VideoInput::~VideoInput() {
|
||||||
if (isStarted()) {
|
if (isStarted()) {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
RWISP_SceneAuto_deinit();
|
||||||
rw_mpp__vdec_finalize();
|
rw_mpp__vdec_finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,17 +92,28 @@ bool VideoInput::startEncode() {
|
|||||||
config.profile = H264_main;
|
config.profile = H264_main;
|
||||||
config.raw_max_width = 2960;
|
config.raw_max_width = 2960;
|
||||||
config.raw_max_height = 1664;
|
config.raw_max_height = 1664;
|
||||||
config.width = 1280;
|
config.width = 1920;
|
||||||
config.height = 720;
|
config.height = 1080;
|
||||||
config.gop = 5;
|
config.gop = 5;
|
||||||
config.framerate = 25;
|
config.framerate = 20;
|
||||||
config.rc_type = RC_VBR;
|
config.rc_type = RC_VBR;
|
||||||
|
// config.rc_type = RC_FIXQP;
|
||||||
|
|
||||||
S_venc_rc_vbr vbr;
|
S_venc_rc_vbr vbr;
|
||||||
memset(&vbr, 0, sizeof(S_venc_rc_vbr));
|
S_venc_rc_fixQp fixQp;
|
||||||
vbr.max_bitrate = 1024;
|
if (config.rc_type == RC_FIXQP) { // RC_FIXQP 其压缩损失比较小
|
||||||
vbr.stats_time = 1;
|
memset(&fixQp, 0, sizeof(S_venc_rc_fixQp));
|
||||||
config.rc_param = &vbr;
|
fixQp.IQp = 20;
|
||||||
|
fixQp.PQp = 20;
|
||||||
|
fixQp.BQp = 20;
|
||||||
|
config.rc_param = &fixQp;
|
||||||
|
} else {
|
||||||
|
memset(&vbr, 0, sizeof(S_venc_rc_vbr));
|
||||||
|
vbr.max_bitrate = 100 * 1024;
|
||||||
|
vbr.stats_time = 1;
|
||||||
|
config.rc_param = &vbr;
|
||||||
|
}
|
||||||
|
|
||||||
int status = rw_mpp__venc_start(m_d->encodeChannel, &config, -1);
|
int status = rw_mpp__venc_start(m_d->encodeChannel, &config, -1);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
LOG(error) << "rw_mpp__venc_start() failed, status: " << status;
|
LOG(error) << "rw_mpp__venc_start() failed, status: " << status;
|
||||||
@ -140,6 +158,7 @@ void VideoInput::setPacketHandler(const PacketHandler &hanlder) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VideoInputPrivate::processImage(S_mpp_img &image, S_mpp_img &detectImage, uint64_t frameIndex) {
|
void VideoInputPrivate::processImage(S_mpp_img &image, S_mpp_img &detectImage, uint64_t frameIndex) {
|
||||||
|
// algorithm.detect(detectImage.nv21);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoInputPrivate::processFrame(S_mpp_img &image) {
|
void VideoInputPrivate::processFrame(S_mpp_img &image) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user