71 lines
2.4 KiB
C++
71 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include "IDroneScrewAlgo.h"
|
|
|
|
#include <atomic>
|
|
#include <mutex>
|
|
#include <vector>
|
|
|
|
#ifdef DRONESCREW_STEREO_BOLT_DIRECT_LINK
|
|
#include "stereo_bolt/c_api.h"
|
|
#else
|
|
struct StereoBoltCtx;
|
|
#endif
|
|
|
|
/**
|
|
* @brief Adapter for AppAlgo/stereo_bolt_delivery.
|
|
*
|
|
* The class name is kept for compatibility with existing project files. The
|
|
* implementation links libstereo_bolt.so directly and feeds left/right Mono8
|
|
* camera buffers to the C API.
|
|
*/
|
|
class DroneScrewAlgoStub : public IDroneScrewAlgo
|
|
{
|
|
public:
|
|
DroneScrewAlgoStub();
|
|
~DroneScrewAlgoStub() override;
|
|
|
|
int Init(const DroneScrewAlgoParams& params) override;
|
|
int UnInit() override;
|
|
int Detect(const DroneScrewInputImage& leftImage,
|
|
const DroneScrewInputImage& rightImage,
|
|
DroneScrewResult& result) override;
|
|
int DetectDistance(const DroneScrewInputImage& leftImage,
|
|
const DroneScrewInputImage& rightImage,
|
|
DroneScrewResult& result) override;
|
|
int UpdateParams(const DroneScrewAlgoParams& params) override;
|
|
std::string GetVersion() const override;
|
|
|
|
private:
|
|
#ifdef DRONESCREW_STEREO_BOLT_DIRECT_LINK
|
|
bool buildRectifiedLeftToRawMap(const StereoBoltCalibC& calib,
|
|
double rectAlpha,
|
|
std::string& error);
|
|
bool mapRectifiedLeftRoi(const StereoBoltModuleRoiC& roi,
|
|
int rawWidth,
|
|
int rawHeight,
|
|
DroneScrewBox& box) const;
|
|
void appendRoiBox(const StereoBoltModuleRoiC& roi,
|
|
DroneScrewResult& result) const;
|
|
void appendBoltBox(const StereoBoltModuleBoltC& bolt,
|
|
DroneScrewResult& result) const;
|
|
#endif
|
|
|
|
DroneScrewAlgoParams m_params;
|
|
StereoBoltCtx* m_ctx{nullptr};
|
|
std::string m_configPath;
|
|
std::string m_calibPath;
|
|
std::string m_modelPath;
|
|
std::string m_initError;
|
|
#ifdef DRONESCREW_STEREO_BOLT_DIRECT_LINK
|
|
StereoBoltCalibC m_calib{};
|
|
double m_rectAlpha{1.0};
|
|
int m_rectMapWidth{0};
|
|
int m_rectMapHeight{0};
|
|
std::vector<float> m_leftRectToRawX;
|
|
std::vector<float> m_leftRectToRawY;
|
|
#endif
|
|
mutable std::mutex m_mutex;
|
|
std::atomic<bool> m_bInited{false};
|
|
};
|