Change lighting length to be based on when cameras report finished
Fix viewer handling when cammeras are available
This commit is contained in:
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
||||
|
70
src/main.cpp
70
src/main.cpp
@ -122,41 +122,44 @@ int main(int argc, char *argv[])
|
||||
|
||||
MainWindow w(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);
|
||||
QObject::connect(&w, &MainWindow::sigCapture, [&cameras](){cameras.start(); cameras.trigger();});
|
||||
|
||||
QTimer temperatureTimer;
|
||||
temperatureTimer.setSingleShot(false);
|
||||
QObject::connect(&temperatureTimer, &QTimer::timeout, [&cameras, &w](){w.setTemperature(cameras.getMeanTemp());});
|
||||
temperatureTimer.start(1000);
|
||||
|
||||
QObject::connect(&w, &MainWindow::sigChooseCameras, [&cameras, &w]()
|
||||
if(!parser.isSet(viewerOption))
|
||||
{
|
||||
bool accepted;
|
||||
std::vector<cam::Camera::Description> descs = showCameraSelectionDialog(&accepted, &w);
|
||||
if(accepted)
|
||||
cameras.setCameras(descs);
|
||||
});
|
||||
QObject::connect(&cameras, &Cameras::cameraAdded, &w, &MainWindow::addCamera);
|
||||
QObject::connect(&cameras, &Cameras::cameraRemoved, &w, &MainWindow::removeCamera);
|
||||
QObject::connect(&cameras, &Cameras::enableCapture, &w, &MainWindow::enableCapture);
|
||||
QObject::connect(&w, &MainWindow::sigCapture, [&cameras](){cameras.start(); cameras.trigger();});
|
||||
|
||||
QObject::connect(&w, &MainWindow::sigEditProfiles, [&cameras, &w](){showProfileDialog(&cameras, &w); w.refreshProfiles();});
|
||||
QObject::connect(&pipe, &ImagePipeline::sigResult, w.mainImageViewer(), &CvImageViewer::setImage, Qt::QueuedConnection);
|
||||
QObject::connect(&pipe, &ImagePipeline::sigResult, [&w](){w.statusMsg("idle");});
|
||||
QObject::connect(&pipe, &ImagePipeline::sigInvalidProfile, &w, &MainWindow::profileInconpatible);
|
||||
QTimer temperatureTimer;
|
||||
temperatureTimer.setSingleShot(false);
|
||||
QObject::connect(&temperatureTimer, &QTimer::timeout, [&cameras, &w](){w.setTemperature(cameras.getMeanTemp());});
|
||||
temperatureTimer.start(1000);
|
||||
|
||||
QObject::connect(&w, &MainWindow::sigProfile, [&pipe](QString name)
|
||||
{
|
||||
Profile profile;
|
||||
profile.load(name);
|
||||
if(profile.cameras.size() != 0)
|
||||
qDebug()<<"loading profile"<<name<<"with"<<profile.cameras.size()<<"cameras and first camera"<<profile.cameras.at(0).id;
|
||||
else
|
||||
qDebug()<<"empty profile!!";
|
||||
pipe.setProfile(profile);
|
||||
});
|
||||
QObject::connect(&w, &MainWindow::sigChooseCameras, [&cameras, &w]()
|
||||
{
|
||||
bool accepted;
|
||||
std::vector<cam::Camera::Description> descs = showCameraSelectionDialog(&accepted, &w);
|
||||
if(accepted)
|
||||
cameras.setCameras(descs);
|
||||
});
|
||||
|
||||
cameras.load(settings);
|
||||
QObject::connect(&w, &MainWindow::sigEditProfiles, [&cameras, &w](){showProfileDialog(&cameras, &w); w.refreshProfiles();});
|
||||
QObject::connect(&pipe, &ImagePipeline::sigResult, w.mainImageViewer(), &CvImageViewer::setImage, Qt::QueuedConnection);
|
||||
QObject::connect(&pipe, &ImagePipeline::sigResult, [&w](){w.statusMsg("idle");});
|
||||
QObject::connect(&pipe, &ImagePipeline::sigInvalidProfile, &w, &MainWindow::profileInconpatible);
|
||||
|
||||
QObject::connect(&w, &MainWindow::sigProfile, [&pipe](QString name)
|
||||
{
|
||||
Profile profile;
|
||||
profile.load(name);
|
||||
if(profile.cameras.size() != 0)
|
||||
qDebug()<<"loading profile"<<name<<"with"<<profile.cameras.size()<<"cameras and first camera"<<profile.cameras.at(0).id;
|
||||
else
|
||||
qDebug()<<"empty profile!!";
|
||||
pipe.setProfile(profile);
|
||||
});
|
||||
|
||||
cameras.load(settings);
|
||||
}
|
||||
|
||||
splash.hide();
|
||||
w.show();
|
||||
@ -183,8 +186,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
ret = a.exec();
|
||||
|
||||
cameras.store(settings);
|
||||
|
||||
if(!parser.isSet(viewerOption))
|
||||
cameras.store(settings);
|
||||
}
|
||||
|
||||
if(uvosledRet >= 0)
|
||||
|
0
src/regessioncalculator.cpp
Executable file → Normal file
0
src/regessioncalculator.cpp
Executable file → Normal file
0
src/regessioncalculator.h
Executable file → Normal file
0
src/regessioncalculator.h
Executable file → Normal file
0
src/ui/aboutdiag.cpp
Executable file → Normal file
0
src/ui/aboutdiag.cpp
Executable file → Normal file
0
src/ui/aboutdiag.h
Executable file → Normal file
0
src/ui/aboutdiag.h
Executable file → Normal file
0
src/ui/aboutdiag.ui
Executable file → Normal file
0
src/ui/aboutdiag.ui
Executable file → Normal 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
0
src/ui/plot.cpp
Executable file → Normal file
0
src/ui/plot.h
Executable file → Normal file
0
src/ui/plot.h
Executable file → Normal file
0
src/ui/regressiondiag.cpp
Executable file → Normal file
0
src/ui/regressiondiag.cpp
Executable file → Normal file
0
src/ui/regressiondiag.h
Executable file → Normal file
0
src/ui/regressiondiag.h
Executable file → Normal file
0
src/ui/regressiondiag.ui
Executable file → Normal file
0
src/ui/regressiondiag.ui
Executable file → Normal file
0
src/ui/statisticsdialog.cpp
Executable file → Normal file
0
src/ui/statisticsdialog.cpp
Executable file → Normal file
0
src/ui/statisticsdialog.h
Executable file → Normal file
0
src/ui/statisticsdialog.h
Executable file → Normal file
0
src/ui/statisticsdialog.ui
Executable file → Normal file
0
src/ui/statisticsdialog.ui
Executable file → Normal file
0
src/utilites.cpp
Executable file → Normal file
0
src/utilites.cpp
Executable file → Normal file
0
src/utilites.h
Executable file → Normal file
0
src/utilites.h
Executable file → Normal file
Reference in New Issue
Block a user