[dualcamgrabber] cleanup
This commit is contained in:
parent
0fa532d59a
commit
cd9bbcfa62
@ -34,14 +34,6 @@ void DualcamGrabber::run() {
|
|||||||
bool failure = false;
|
bool failure = false;
|
||||||
|
|
||||||
auto before = high_resolution_clock::now();
|
auto before = high_resolution_clock::now();
|
||||||
auto after = high_resolution_clock::now();
|
|
||||||
auto after1 = high_resolution_clock::now();
|
|
||||||
auto stitch = high_resolution_clock::now();
|
|
||||||
auto stitchncopy = high_resolution_clock::now();
|
|
||||||
auto grab_duration = duration_cast<microseconds>(after - before);
|
|
||||||
auto grab1_duration = duration_cast<microseconds>(after1 - before);
|
|
||||||
auto stitch_duration = duration_cast<microseconds>(stitch - after);
|
|
||||||
auto stitchncopy_duration = duration_cast<microseconds>(stitchncopy - after);
|
|
||||||
auto done = high_resolution_clock::now();
|
auto done = high_resolution_clock::now();
|
||||||
auto total_duration = duration_cast<microseconds>(done - before);
|
auto total_duration = duration_cast<microseconds>(done - before);
|
||||||
int expected_usecs = (int)(1./framerate * 1000000);
|
int expected_usecs = (int)(1./framerate * 1000000);
|
||||||
@ -52,13 +44,12 @@ void DualcamGrabber::run() {
|
|||||||
if (delay > 0) {
|
if (delay > 0) {
|
||||||
emit delayed(delay, counter-1);
|
emit delayed(delay, counter-1);
|
||||||
} else {
|
} else {
|
||||||
// std::cerr << "expected ifi " << expected_usecs << " real ifi: " << total_duration.count() << " waiting for " << (-1*delay) << std::endl;
|
|
||||||
usleep(-delay);
|
usleep(-delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
before = high_resolution_clock::now();
|
before = high_resolution_clock::now();
|
||||||
|
|
||||||
if (cameras[0].WaitForFrameTriggerReady(1000, Pylon::TimeoutHandling_ThrowException) &
|
if (cameras[0].WaitForFrameTriggerReady(1000, Pylon::TimeoutHandling_ThrowException) &&
|
||||||
cameras[1].WaitForFrameTriggerReady(1000, Pylon::TimeoutHandling_ThrowException)) {
|
cameras[1].WaitForFrameTriggerReady(1000, Pylon::TimeoutHandling_ThrowException)) {
|
||||||
// std::cerr << "executing software triggers" << std::endl;
|
// std::cerr << "executing software triggers" << std::endl;
|
||||||
cameras[0].ExecuteSoftwareTrigger();
|
cameras[0].ExecuteSoftwareTrigger();
|
||||||
@ -67,20 +58,17 @@ void DualcamGrabber::run() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
cameras[0].RetrieveResult( 5000, frame0, Pylon::TimeoutHandling_ThrowException );
|
cameras[0].RetrieveResult( 5000, frame0, Pylon::TimeoutHandling_ThrowException );
|
||||||
after1 = high_resolution_clock::now();
|
|
||||||
cameras[1].RetrieveResult( 5000, frame1, Pylon::TimeoutHandling_ThrowException );
|
cameras[1].RetrieveResult( 5000, frame1, Pylon::TimeoutHandling_ThrowException );
|
||||||
leftImage.AttachGrabResultBuffer( frame0 );
|
leftImage.AttachGrabResultBuffer( frame0 );
|
||||||
rightImage.AttachGrabResultBuffer( frame1 );
|
rightImage.AttachGrabResultBuffer( frame1 );
|
||||||
} catch( ... ) {
|
} catch( const Pylon::GenericException &e ) {
|
||||||
qDebug() << "Grabbing frame failed! " << e.what();
|
qDebug() << "Grabbing frame failed! " << e.what();
|
||||||
failure = true
|
failure = true;
|
||||||
}
|
}
|
||||||
after = high_resolution_clock::now();
|
|
||||||
|
|
||||||
if (!failure && leftImage.IsValid() && rightImage.IsValid()) {
|
if (!failure && leftImage.IsValid() && rightImage.IsValid()) {
|
||||||
try {
|
try {
|
||||||
StitchImage::StitchToRight(leftImage, rightImage, &stitchedImage, errorMessage);
|
StitchImage::StitchToRight(leftImage, rightImage, &stitchedImage, errorMessage);
|
||||||
stitch = high_resolution_clock::now();
|
|
||||||
MyImage *img = new MyImage(stitchedImage.GetWidth(), stitchedImage.GetHeight());
|
MyImage *img = new MyImage(stitchedImage.GetWidth(), stitchedImage.GetHeight());
|
||||||
img->setFrame(stitchedImage);
|
img->setFrame(stitchedImage);
|
||||||
buffer->push(img);
|
buffer->push(img);
|
||||||
@ -89,18 +77,9 @@ void DualcamGrabber::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stitchncopy = high_resolution_clock::now();
|
counter += 1;
|
||||||
grab_duration = duration_cast<microseconds>(after - before);
|
|
||||||
grab1_duration = duration_cast<microseconds>(after1 - before);
|
|
||||||
stitch_duration = duration_cast<microseconds>(stitch - after);
|
|
||||||
stitchncopy_duration = duration_cast<microseconds>(stitchncopy - after);
|
|
||||||
// std::cerr << "framecount: " << counter << " grab1_duration (us): " << grab1_duration.count() << " grab_all (us): " << grab_duration.count() << std::endl;
|
|
||||||
// std::cerr << "\tpure stich (us): " << stitch_duration.count() << " stich'n'copy (us): " << stitchncopy_duration.count() << std::endl;
|
|
||||||
done = high_resolution_clock::now();
|
done = high_resolution_clock::now();
|
||||||
total_duration = duration_cast<microseconds>(done - before);
|
total_duration = duration_cast<microseconds>(done - before);
|
||||||
// double rate = (1./((double)total_duration.count()/1000000));
|
|
||||||
// std::cerr << "total_duration (us): " << total_duration.count() << " rate: " << rate << std::endl;
|
|
||||||
counter += 1;
|
|
||||||
}
|
}
|
||||||
cameras.StopGrabbing();
|
cameras.StopGrabbing();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user