@@ -148,27 +148,17 @@ bool MvCam::Initialization() {
148148 return false ;
149149 }
150150}
151- void MvCam::Restart () {
152- Stop ();
153- std::this_thread::sleep_for (std::chrono::milliseconds{500 });
154- if (!Initialization ()) {
155- LOG (INFO) << " Camera initialization failed after restart!" ;
156- } else {
157- Start ();
158- LOG (INFO) << " Cameras successfully restarted!" ;
159- }
160- }
161151
162152void MvCam::Stop () {
163153 Disable ();
164154 std::this_thread::sleep_for (std::chrono::milliseconds{500 });
165- for (auto &cam_thread : cam_threads_ ) {
155+ for (auto &cam_thread : cam_threads ) {
166156 while (cam_thread.joinable ()) {
167157 cam_thread.join ();
168158 }
169159 }
170- cam_threads_ .clear ();
171- cam_threads_ .shrink_to_fit ();
160+ cam_threads .clear ();
161+ cam_threads .shrink_to_fit ();
172162 for (size_t i = 0 ; i < handles_.size (); ++i) {
173163 int n_ret = MV_OK;
174164 n_ret = MV_CC_StopGrabbing (handles_[i]);
@@ -193,7 +183,7 @@ void MvCam::Receive(void *handle, const std::string &name) {
193183 MV_FRAME_OUT st_out_frame;
194184 CamData cam_data;
195185 Messenger &messenger = Messenger::GetInstance ();
196- while (is_running_ ) {
186+ while (is_running ) {
197187 memset (&st_out_frame, 0 , sizeof (MV_FRAME_OUT));
198188 int n_ret = MV_CC_GetImageBuffer (handle, &st_out_frame, 10 );
199189 if (n_ret == MV_OK) {
@@ -203,11 +193,11 @@ void MvCam::Receive(void *handle, const std::string &name) {
203193 LOG (ERROR) << " Get ExposureTime fail! n_ret [0x" << std::hex << n_ret << " ]" ;
204194 }
205195 // 这里的time_stamp_us是相机触发时间,需要加上曝光时间的一半,以获得相机拍摄的时间
206- if (params_ .find (name) == params_ .end ()) {
196+ if (params .find (name) == params .end ()) {
207197 LOG (ERROR) << " cam " << name << " not found!" ;
208198 }
209199 else {
210- if (uint64_t time; GET_LAST_TRIGGER_STATUS (params_ [name], time)) {
200+ if (uint64_t time; GET_LAST_TRIGGER_STATUS (params [name], time)) {
211201 cam_data.time_stamp_us = time + static_cast <uint64_t >(expose_time.fCurValue / 2 .);
212202 }
213203 else {
@@ -272,7 +262,7 @@ void MvCam::Start() {
272262 name = " cam_" + std::to_string (cam_index++);
273263 LOG (WARNING) << " Camera name is empty,create name " << name;
274264 }
275- cam_threads_ .emplace_back (&MvCam::Receive, this , handle, name);
265+ cam_threads .emplace_back (&MvCam::Receive, this , handle, name);
276266 LOG (INFO) << " Camera name is " << name << " start" ;
277267 }
278268}
0 commit comments