Change lighting length to be based on when cameras report finished

Fix viewer handling when cammeras are available
This commit is contained in:
uvos
2021-07-19 11:12:23 +02:00
parent 65cdc7b78f
commit a9f263b22d
21 changed files with 67 additions and 36 deletions

View File

@ -6,9 +6,9 @@ Version=1.0
# The name of the application
Name=Lubricant Thickness Detector
# A comment which can/will be used as a tooltip
Comment=MAClient -sd 0 -t 30
Comment=MAClient
# The executable of the application, possibly with arguments.
Exec=MAClient
Exec=MAClient -sd 0 -t 30
# The name of the icon that will be used to display this entry
Icon=MAClient
# Describes whether this application needs to be run in a terminal or not

View File

@ -157,13 +157,20 @@ void Cameras::trigger()
if(serial_)
{
if(captureingCamera == 0)
lightFor(lighting_, exposrueTime_*1.5*cameras_.size());
{
lightFor(lighting_, 10000);
qDebug()<<__func__<<"started";
std::this_thread::sleep_for(std::chrono::microseconds(static_cast<long>(exposrueTime_)));
}
cameras_[captureingCamera]->cam()->trigger();
++captureingCamera;
if(captureingCamera < cameras_.size())
QTimer::singleShot(exposrueTime_*1000, this, &Cameras::trigger);
else
{
captureingCamera = 0;
qDebug()<<__func__<<"finished";
}
}
else
{
@ -271,6 +278,7 @@ void Cameras::imageRecived(Camera::Image img)
if(images_.size() == cameras_.size())
{
lightOff();
cameraFailureTimer.stop();
newImages(images_);
images_.clear();

View File

@ -7,6 +7,7 @@
#include <QDebug>
#include <algorithm>
#include <opencv2/highgui.hpp>
#include <math.h>
ImagePipeline::ImagePipeline(Cameras* cameras, bool simpleStichingAlg, QObject *parent):
QObject(parent), cameras_(cameras), simpleStichingAlg_(simpleStichingAlg)
@ -43,6 +44,19 @@ void ImagePipeline::applyDarkMap(cv::Mat& image, const cv::Mat& darkmap)
image = subtracted;
}
void ImagePipeline::sanityCheckMap(cv::Mat& mat)
{
for(int y = 0; y < mat.rows; y++)
{
float* col = mat.ptr<float>(y);
for(int x = 0; x < mat.cols; ++x)
{
if(isnan(col[x]) || isinf(col[x]))
col[x] = 0.5;
}
}
}
cv::Mat ImagePipeline::process(const Profile profile, std::vector<Camera::Image> images, bool simpleStichingAlg)
{
qDebug()<<__func__<<"got"<<images.size()<<"images";
@ -136,6 +150,9 @@ cv::Mat ImagePipeline::process(const Profile profile, std::vector<Camera::Image>
if(profile.calcurve.data)
applyCurve(output, profile.calcurve);
sanityCheckMap(output);
return output;
}
else

View File

@ -23,6 +23,7 @@ private:
static cv::Mat process(const Profile profile, std::vector<Camera::Image> images, bool simpleStich);
static void applyDarkMap(cv::Mat& image, const cv::Mat &darkmap);
static void sanityCheckMap(cv::Mat& mat);
private slots:

View File

@ -122,6 +122,8 @@ int main(int argc, char *argv[])
MainWindow w(parser.isSet(viewerOption));
if(!parser.isSet(viewerOption))
{
QObject::connect(&cameras, &Cameras::cameraAdded, &w, &MainWindow::addCamera);
QObject::connect(&cameras, &Cameras::cameraRemoved, &w, &MainWindow::removeCamera);
QObject::connect(&cameras, &Cameras::enableCapture, &w, &MainWindow::enableCapture);
@ -157,6 +159,7 @@ int main(int argc, char *argv[])
});
cameras.load(settings);
}
splash.hide();
w.show();
@ -184,6 +187,7 @@ int main(int argc, char *argv[])
ret = a.exec();
if(!parser.isSet(viewerOption))
cameras.store(settings);
}

0
src/regessioncalculator.cpp Executable file → Normal file
View File

0
src/regessioncalculator.h Executable file → Normal file
View File

0
src/ui/aboutdiag.cpp Executable file → Normal file
View File

0
src/ui/aboutdiag.h Executable file → Normal file
View File

0
src/ui/aboutdiag.ui Executable file → Normal file
View File

View File

@ -186,6 +186,7 @@ void CvImageViewer::convertImage(cv::Mat image)
void CvImageViewer::setImage(Camera::Image img)
{
origImage_=img.mat;
clamp_ = std::numeric_limits<double>::max();
qDebug()<<"viwer got"<<image_.rows<<'x'<<image_.cols<<" type "<<image_.type()<<"image from camera"<<img.cameraId;
convertImage(img.mat);
update();

0
src/ui/plot.cpp Executable file → Normal file
View File

0
src/ui/plot.h Executable file → Normal file
View File

0
src/ui/regressiondiag.cpp Executable file → Normal file
View File

0
src/ui/regressiondiag.h Executable file → Normal file
View File

0
src/ui/regressiondiag.ui Executable file → Normal file
View File

0
src/ui/statisticsdialog.cpp Executable file → Normal file
View File

0
src/ui/statisticsdialog.h Executable file → Normal file
View File

0
src/ui/statisticsdialog.ui Executable file → Normal file
View File

0
src/utilites.cpp Executable file → Normal file
View File

0
src/utilites.h Executable file → Normal file
View File