Skip to content

Commit af5fbc8

Browse files
committed
cam add tigger time
1 parent eecd424 commit af5fbc8

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

infinite_sense_core/include/cam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CamManger {
2020
void Restart();
2121

2222
private:
23-
void Receive(void* handle, const std::string&) const;
23+
void Receive(void* handle, const std::string&);
2424
bool is_running_{false};
2525
std::vector<int> rets_;
2626
std::vector<void*> handles_;

infinite_sense_core/src/cam.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "infinite_sense.h"
33
#include "MvCameraControl.h"
44
#include "log.h"
5-
5+
#include "trigger.h"
66
namespace infinite_sense {
77
bool IsColor(const MvGvspPixelType type) {
88
switch (type) {
@@ -190,7 +190,7 @@ void CamManger::Stop() {
190190
LOG(INFO) << "Exit " << i << " cam ";
191191
}
192192
}
193-
void CamManger::Receive(void *handle, const std::string &name) const {
193+
void CamManger::Receive(void *handle, const std::string &name) {
194194
unsigned int last_count = 0;
195195
MV_FRAME_OUT st_out_frame;
196196
CamData cam_data;
@@ -204,10 +204,18 @@ void CamManger::Receive(void *handle, const std::string &name) const {
204204
if (n_ret != MV_OK) {
205205
LOG(ERROR) << "Get ExposureTime fail! n_ret [0x" << std::hex << n_ret << "]";
206206
}
207-
// {
208-
// cam_data.time_stamp_us =
209-
// DataManger::GetInstance().GetLastTiggerTime() + static_cast<uint64_t>(expose_time.fCurValue / 2.);
210-
// }
207+
// 这里的time_stamp_us是相机触发时间,需要加上曝光时间的一半,以获得相机拍摄的时间
208+
if (params_.find(name) == params_.end()) {
209+
LOG(ERROR) << "cam " << name << " not found!";
210+
}
211+
else {
212+
if (uint64_t time; GET_LAST_TRIGGER_STATUS(params_[name], time)) {
213+
cam_data.time_stamp_us = time + static_cast<uint64_t>(expose_time.fCurValue / 2.);
214+
}
215+
else {
216+
LOG(ERROR) << "cam " << name << " not found!";
217+
}
218+
}
211219
MvGvspPixelType en_dst_pixel_type = PixelType_Gvsp_Undefined;
212220
unsigned int n_channel_num = 0;
213221
// 如果是彩色则转成RGB8

0 commit comments

Comments
 (0)