修改参数传递方式,避免内存提前被释放

streaming
Matthew 4 months ago
parent 4686003763
commit 6162c220b4

@ -296,7 +296,7 @@ CPhoneDevice::CPhoneCamera::~CPhoneCamera()
m_dev = NULL;
}
bool CPhoneDevice::CPhoneCamera::on_image(cv::Mat& rgb)
bool CPhoneDevice::CPhoneCamera::on_image(cv::Mat rgb)
{
if (m_dev != NULL)
{
@ -3046,7 +3046,7 @@ int CPhoneDevice::CallExecv(int rotation, int frontCamera, const std::string& ou
return exitCode;
}
bool CPhoneDevice::OnImageReady(cv::Mat& mat)
bool CPhoneDevice::OnImageReady(cv::Mat mat)
{
time_t takingTime = time(NULL);
if (mPhotoInfo.remedy != 0)
@ -3364,7 +3364,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
return res;
}
bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<IDevice::OSD_INFO>& osds, const std::string& path, const std::string& cameraInfo, cv::Mat& mat)
bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<IDevice::OSD_INFO>& osds, const std::string& path, const std::string& cameraInfo, cv::Mat mat)
{
int baseline = 0;
cv::Size textSize;
@ -3598,6 +3598,12 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<ID
strcpy(log, fullPath.c_str());
#endif
bool res = cv::imwrite(fullPath.c_str(), mat, params);
#ifdef _DEBUG
if (getFileSize(fullPath.c_str()) == 0)
{
int aa = 0;
}
#endif
if (!res)
{
XYLOG(XYLOG_SEVERITY_ERROR, "Failed to Write File: %s", fullPath.c_str() + m_appPath.size());
@ -3616,7 +3622,7 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<ID
return res;
}
bool CPhoneDevice::OnCaptureReady(bool photoOrVideo, bool result, cv::Mat& mat, unsigned int photoId)
bool CPhoneDevice::OnCaptureReady(bool photoOrVideo, bool result, cv::Mat mat, unsigned int photoId)
{
XYLOG(XYLOG_SEVERITY_INFO, "RAW Capture finished: %u RES=%d", photoId, (result ? 1 : 0));
if (photoOrVideo)

@ -172,7 +172,7 @@ public:
public:
CPhoneCamera(CPhoneDevice* dev, int32_t width, int32_t height, const NdkCamera::CAMERA_PARAMS& params);
virtual ~CPhoneCamera();
virtual bool on_image(cv::Mat& rgb);
virtual bool on_image(cv::Mat rgb);
virtual void on_error(const std::string& msg);
virtual void onDisconnected(ACameraDevice* device);
virtual bool onBurstCapture(std::shared_ptr<ACameraMetadata> characteristics, std::vector<std::shared_ptr<ACameraMetadata> >& results, uint32_t ldr, uint32_t duration, std::vector<std::vector<uint8_t> >& frames);
@ -248,7 +248,7 @@ public:
void UpdatePosition(double lon, double lat, double radius, time_t ts);
bool OnVideoReady(bool photoOrVideo, bool result, const char* path, unsigned int photoId);
bool OnCaptureReady(bool photoOrVideo, bool result, cv::Mat& mat, unsigned int photoId);
bool OnCaptureReady(bool photoOrVideo, bool result, cv::Mat mat, unsigned int photoId);
void UpdateSignalLevel(int signalLevel);
void UpdateTfCardPath(const std::string& tfCardPath)
@ -273,7 +273,7 @@ protected:
// bool MatchCaptureSizeRequest(ACameraManager *cameraManager, const char *selectedCameraId, unsigned int width, unsigned int height, uint32_t cameraOrientation_,
bool TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, const std::string& path, std::vector<IDevice::OSD_INFO>& osds, std::shared_ptr<PowerControl> powerCtrlPtr);
bool PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<IDevice::OSD_INFO>& osds, const std::string& path, const std::string& cameraInfo, cv::Mat& mat);
bool PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<IDevice::OSD_INFO>& osds, const std::string& path, const std::string& cameraInfo, cv::Mat mat);
inline bool TakePhotoCb(int res, const IDevice::PHOTO_INFO& photoInfo, const string& path, time_t photoTime, const std::vector<IDevice::RECOG_OBJECT>& objects) const
{
if (m_listener != NULL)
@ -318,7 +318,7 @@ protected:
void QueryPowerInfo(std::map<std::string, std::string>& powerInfo);
std::string QueryCpuTemperature();
bool OnImageReady(cv::Mat& mat);
bool OnImageReady(cv::Mat mat);
bool onOneCapture(std::shared_ptr<ACameraMetadata> characteristics, std::shared_ptr<ACameraMetadata> results, uint32_t ldr, uint32_t duration, cv::Mat rgb);
bool onBurstCapture(std::shared_ptr<ACameraMetadata> characteristics, std::vector<std::shared_ptr<ACameraMetadata> >& results, uint32_t ldr, uint32_t duration, std::vector<std::vector<uint8_t> >& frames);
bool onBurstCapture(std::shared_ptr<ACameraMetadata> characteristics, std::vector<std::shared_ptr<ACameraMetadata> >& results, uint32_t ldr, uint32_t duration, std::vector<std::shared_ptr<AImage> >& frames);

@ -1376,7 +1376,7 @@ void NdkCamera::onDisconnected(ACameraDevice* device)
{
}
bool NdkCamera::on_image(cv::Mat& rgb)
bool NdkCamera::on_image(cv::Mat rgb)
{
return false;
}

@ -165,7 +165,7 @@ public:
void DestroySession();
virtual bool on_image(cv::Mat& rgb);
virtual bool on_image(cv::Mat rgb);
virtual void on_error(const std::string& msg);
virtual void on_image(const unsigned char* nv21, int nv21_width, int nv21_height);
virtual void onDisconnected(ACameraDevice* device);

Loading…
Cancel
Save