mainny ui improcements
This commit is contained in:
BIN
res/icon.png
Normal file
BIN
res/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
@ -2,5 +2,6 @@
|
|||||||
<qresource prefix="/images">
|
<qresource prefix="/images">
|
||||||
<file>noimage.png</file>
|
<file>noimage.png</file>
|
||||||
<file>splash.png</file>
|
<file>splash.png</file>
|
||||||
|
<file>icon.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
Camera::Camera(cam::Camera::Description desc)
|
Camera::Camera(cam::Camera::Description desc)
|
||||||
{
|
{
|
||||||
cameraId_ = desc.getHash();
|
cameraId_ = desc.getId();
|
||||||
std::function<void(cv::Mat)> cb = [this](cv::Mat image){newImage(Image(image, cameraId_));};
|
std::function<void(cv::Mat)> cb = [this](cv::Mat image){newImage(Image(image, cameraId_));};
|
||||||
camera_ = new cam::Camera(cb);
|
camera_ = new cam::Camera(cb);
|
||||||
camera_->openCamera(desc);
|
camera_->openCamera(desc);
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
Cameras::Cameras(uvosled* led): led_(led)
|
Cameras::Cameras(uvosled* led): led_(led)
|
||||||
{
|
{
|
||||||
@ -46,7 +48,7 @@ std::shared_ptr<Camera> Cameras::getCamera(size_t id)
|
|||||||
std::vector<cam::Camera::Description> desc = getCameras();
|
std::vector<cam::Camera::Description> desc = getCameras();
|
||||||
for(size_t i = 0; i < desc.size(); ++i)
|
for(size_t i = 0; i < desc.size(); ++i)
|
||||||
{
|
{
|
||||||
if(desc[i].getHash() == id)
|
if(desc[i].getId() == id)
|
||||||
return cameras_[i];
|
return cameras_[i];
|
||||||
}
|
}
|
||||||
return std::shared_ptr<Camera>(nullptr);
|
return std::shared_ptr<Camera>(nullptr);
|
||||||
@ -62,14 +64,35 @@ bool Cameras::addCamera(const cam::Camera::Description& desc)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cameras_.back()->cam()->setTriggerMode(cam::Camera::TRIGGER_SOFTWARE);
|
|
||||||
cameras_.back()->cam()->setExposureTime(exposrueTime_*1000000);
|
cameras_.back()->cam()->setExposureTime(exposrueTime_*1000000);
|
||||||
setFree(false);
|
|
||||||
cameraAdded(cameras_.back());
|
if(desc.getVendor().find("Photonfocus") != std::string::npos)
|
||||||
qDebug()<<"Using camera"<<cameras_.back()->id();
|
{
|
||||||
|
qDebug()<<"Mitiagting broken PhotonFocus single shot mode";
|
||||||
|
std::shared_ptr<Camera> camera = cameras_.back();
|
||||||
|
camera->cam()->setTriggerMode(cam::Camera::TRIGGER_FREE);
|
||||||
|
camera->cam()->setAcquisitionMode(cam::Camera::MODE_FREE);
|
||||||
|
camera->cam()->setFrameRate(10);
|
||||||
|
camera->cam()->startAcquisition();
|
||||||
|
QTimer::singleShot(2000, [camera, this](){finishAddCamera(camera);});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
finishAddCamera(cameras_.back());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cameras::finishAddCamera(std::shared_ptr<Camera> camera)
|
||||||
|
{
|
||||||
|
camera->cam()->setTriggerMode(cam::Camera::TRIGGER_SOFTWARE);
|
||||||
|
setFree(free_);
|
||||||
|
connect(camera.get(), &Camera::newImage, this, &Cameras::imageRecived);
|
||||||
|
qDebug()<<"Using camera"<<camera->id();
|
||||||
|
cameraAdded(camera);
|
||||||
|
}
|
||||||
|
|
||||||
void Cameras::trigger()
|
void Cameras::trigger()
|
||||||
{
|
{
|
||||||
for(auto& camera : cameras_)
|
for(auto& camera : cameras_)
|
||||||
@ -108,6 +131,11 @@ bool Cameras::stop()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cameras::disable(bool disable)
|
||||||
|
{
|
||||||
|
disable_ = disable;
|
||||||
|
}
|
||||||
|
|
||||||
bool Cameras::setFree(bool free)
|
bool Cameras::setFree(bool free)
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
@ -117,8 +145,11 @@ bool Cameras::setFree(bool free)
|
|||||||
for(auto& camera : cameras_)
|
for(auto& camera : cameras_)
|
||||||
{
|
{
|
||||||
if(!camera->cam()->setAcquisitionMode(free ? cam::Camera::MODE_FREE : cam::Camera::MODE_SINGLE))
|
if(!camera->cam()->setAcquisitionMode(free ? cam::Camera::MODE_FREE : cam::Camera::MODE_SINGLE))
|
||||||
|
{
|
||||||
|
qDebug()<<"failed to set single on camera"<<camera->id();
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,36 +161,42 @@ bool Cameras::setExposureTime(double exposureTime)
|
|||||||
for(auto& camera : cameras_)
|
for(auto& camera : cameras_)
|
||||||
{
|
{
|
||||||
if(!camera->cam()->setExposureTime(exposrueTime_*1000000))
|
if(!camera->cam()->setExposureTime(exposrueTime_*1000000))
|
||||||
|
{
|
||||||
|
qDebug()<<"failed to set exposure on camera"<<camera->id();
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cameras::imageRecived(Camera::Image img)
|
void Cameras::imageRecived(Camera::Image img)
|
||||||
{
|
{
|
||||||
bool allreadyUpdated = false;
|
if(!disable_)
|
||||||
for(auto& camera : cameras_)
|
|
||||||
{
|
{
|
||||||
|
bool allreadyUpdated = false;
|
||||||
for(auto& image : images_)
|
for(auto& image : images_)
|
||||||
{
|
{
|
||||||
if(image.cameraId == camera->id())
|
if(image.cameraId == img.cameraId)
|
||||||
{
|
{
|
||||||
allreadyUpdated = true;
|
allreadyUpdated = true;
|
||||||
goto FOUND;
|
break;;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
FOUND:
|
|
||||||
|
|
||||||
if(!allreadyUpdated)
|
if(!allreadyUpdated)
|
||||||
images_.push_back(img);
|
images_.push_back(img);
|
||||||
|
|
||||||
if(images_.size() == cameras_.size())
|
qDebug()<<"Recived"<<images_.size()<<"of"<<cameras_.size()<<"images";
|
||||||
newImages(images_);
|
|
||||||
|
|
||||||
|
if(images_.size() == cameras_.size())
|
||||||
|
{
|
||||||
|
newImages(images_);
|
||||||
images_.clear();
|
images_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Cameras::store(QSettings &settings)
|
void Cameras::store(QSettings &settings)
|
||||||
{
|
{
|
||||||
std::vector<cam::Camera::Description> available = cam::Camera::getAvailableCameras();
|
std::vector<cam::Camera::Description> available = cam::Camera::getAvailableCameras();
|
||||||
@ -184,7 +221,7 @@ void Cameras::load(QSettings &settings)
|
|||||||
size_t hash = settings.value("id", 0).toULongLong();
|
size_t hash = settings.value("id", 0).toULongLong();
|
||||||
for(auto& camera : available)
|
for(auto& camera : available)
|
||||||
{
|
{
|
||||||
if(camera.getHash() == hash)
|
if(camera.getId() == hash)
|
||||||
addCamera(camera);
|
addCamera(camera);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ private:
|
|||||||
|
|
||||||
uvosled* led_;
|
uvosled* led_;
|
||||||
bool free_ = false;
|
bool free_ = false;
|
||||||
|
bool disable_ = false;
|
||||||
double exposrueTime_ = 1.0/60.0;
|
double exposrueTime_ = 1.0/60.0;
|
||||||
LightingSetup lighting_;
|
LightingSetup lighting_;
|
||||||
std::vector<std::shared_ptr<Camera>> cameras_;
|
std::vector<std::shared_ptr<Camera>> cameras_;
|
||||||
@ -30,11 +31,12 @@ private:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void imageRecived(Camera::Image img);
|
void imageRecived(Camera::Image img);
|
||||||
|
void finishAddCamera(std::shared_ptr<Camera> camera);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void cameraRemoved(std::shared_ptr<Camera> camera);
|
void cameraRemoved(std::shared_ptr<Camera> camera);
|
||||||
void cameraAdded(std::shared_ptr<Camera> camera);
|
void cameraAdded(std::shared_ptr<Camera> camera);
|
||||||
void newImages(std::vector<Camera::Image> images_);
|
void newImages(std::vector<Camera::Image> images);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
@ -55,6 +57,7 @@ public:
|
|||||||
Cameras(uvosled* led = nullptr);
|
Cameras(uvosled* led = nullptr);
|
||||||
void load(QSettings& settings);
|
void load(QSettings& settings);
|
||||||
void store(QSettings& settings);
|
void store(QSettings& settings);
|
||||||
|
void disable(bool disable);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CAMERAS_H
|
#endif // CAMERAS_H
|
||||||
|
@ -1,38 +1,97 @@
|
|||||||
#include "imagepipeline.h"
|
#include "imagepipeline.h"
|
||||||
#include <uvosunwrap/unwrap.h>
|
#include <uvosunwrap/unwrap.h>
|
||||||
|
#include <uvosunwrap/normalize.h>
|
||||||
|
#include <uvosunwrap/curve.h>
|
||||||
#include <QtConcurrent/QtConcurrentRun>
|
#include <QtConcurrent/QtConcurrentRun>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
ImagePipeline::ImagePipeline(Cameras* cameras, QObject *parent): QObject(parent), cameras_(cameras)
|
ImagePipeline::ImagePipeline(Cameras* cameras, QObject *parent): QObject(parent), cameras_(cameras)
|
||||||
{
|
{
|
||||||
|
connect(cameras_, &Cameras::newImages, this, &ImagePipeline::apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::Mat ImagePipeline::process(const Profile profile, std::vector<Camera::Image> images)
|
cv::Mat ImagePipeline::process(const Profile profile, std::vector<Camera::Image> images)
|
||||||
{
|
{
|
||||||
|
qDebug()<<__FUNCTION__<<"got"<<images.size()<<"images";
|
||||||
std::vector<RemapedImage> remapedImages;
|
std::vector<RemapedImage> remapedImages;
|
||||||
remapedImages.reserve(images.size());
|
remapedImages.reserve(images.size());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(profile.nodistort && images.size() > 0)
|
||||||
|
{
|
||||||
|
for(auto& image : images)
|
||||||
|
{
|
||||||
|
if(profile.cameras[0].id == image.cameraId)
|
||||||
|
{
|
||||||
|
RemapedImage img;
|
||||||
|
img.origin.x = 0;
|
||||||
|
img.origin.y = 0;
|
||||||
|
image.mat.copyTo(img.image);
|
||||||
|
if(profile.cameras[0].darkmap.data)
|
||||||
|
img.image = img.image - profile.cameras[0].darkmap;
|
||||||
|
remapedImages.push_back(img);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for(Camera::Image& image : images)
|
for(Camera::Image& image : images)
|
||||||
{
|
{
|
||||||
|
qDebug()<<__FUNCTION__<<"image cam id"<<image.cameraId;
|
||||||
|
bool matched = false;
|
||||||
for(auto& camera : profile.cameras)
|
for(auto& camera : profile.cameras)
|
||||||
{
|
{
|
||||||
if(camera.id == image.cameraId)
|
if(camera.id == image.cameraId)
|
||||||
{
|
{
|
||||||
if(camera.darkmap.data)
|
if(camera.darkmap.data)
|
||||||
image.mat = image.mat - camera.darkmap;
|
{
|
||||||
|
cv::Mat subtracted;
|
||||||
|
image.mat.copyTo(subtracted);
|
||||||
|
qDebug()<<"Camera"<<camera.id<<"has darkmap"<<image.mat.type()<<camera.darkmap.type();
|
||||||
|
subtracted = image.mat - camera.darkmap;
|
||||||
|
image.mat = subtracted;
|
||||||
|
}
|
||||||
|
RemapedImage remaped = applyRemap(image.mat, camera.remapMap);
|
||||||
|
qDebug()<<"Camera"<<camera.id<<"image remaped to"<<remaped.image.data<<remaped.image.rows<<remaped.image.cols
|
||||||
|
<<"at"<<remaped.origin.x<<'x'<<remaped.origin.y;
|
||||||
remapedImages.push_back(applyRemap(image.mat, camera.remapMap));
|
remapedImages.push_back(applyRemap(image.mat, camera.remapMap));
|
||||||
|
matched = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!matched)
|
||||||
|
qWarning()<<"non matching image recived";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(cv::Exception ex)
|
||||||
|
{
|
||||||
|
qDebug()<<ex.err.c_str();
|
||||||
|
qDebug()<<"Image pipe failure";
|
||||||
|
return cv::Mat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(remapedImages.size() > 0)
|
||||||
|
{
|
||||||
cv::Mat output = simpleStich(remapedImages);
|
cv::Mat output = simpleStich(remapedImages);
|
||||||
output.convertTo(output, CV_32FC1, 1.0/255.0, 0);
|
output.convertTo(output, CV_32FC1, 1.0/255.0, 0);
|
||||||
|
|
||||||
if(profile.lightmap.data)
|
if(profile.lightmap.data)
|
||||||
normalize(output, profile.lightmap);
|
normalize(output, profile.lightmap);
|
||||||
|
|
||||||
|
if(profile.calcurve.data)
|
||||||
|
applyCurve(output, profile.calcurve);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Image pipe failure insufficant matched images";
|
||||||
|
return cv::Mat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ImagePipeline::apply(std::vector<Camera::Image> images)
|
void ImagePipeline::apply(std::vector<Camera::Image> images)
|
||||||
{
|
{
|
||||||
@ -41,6 +100,7 @@ void ImagePipeline::apply(std::vector<Camera::Image> images)
|
|||||||
futureImageWatchers_.push_back(new QFutureWatcher<cv::Mat>());
|
futureImageWatchers_.push_back(new QFutureWatcher<cv::Mat>());
|
||||||
connect(futureImageWatchers_.back(), &QFutureWatcher<cv::Mat>::finished, this, &ImagePipeline::imageFinished);
|
connect(futureImageWatchers_.back(), &QFutureWatcher<cv::Mat>::finished, this, &ImagePipeline::imageFinished);
|
||||||
|
|
||||||
|
statusMsg("Processing");
|
||||||
QFuture<cv::Mat> futureImage = QtConcurrent::run(&ImagePipeline::process, profile_, images);
|
QFuture<cv::Mat> futureImage = QtConcurrent::run(&ImagePipeline::process, profile_, images);
|
||||||
futureImageWatchers_.back()->setFuture(futureImage);
|
futureImageWatchers_.back()->setFuture(futureImage);
|
||||||
}
|
}
|
||||||
@ -51,11 +111,20 @@ void ImagePipeline::setProfile(const Profile& profile)
|
|||||||
profile_ = profile;
|
profile_ = profile;
|
||||||
cameras_->setExposureTime(profile_.exposureTime);
|
cameras_->setExposureTime(profile_.exposureTime);
|
||||||
cameras_->setLighting(profile_.lighting);
|
cameras_->setLighting(profile_.lighting);
|
||||||
|
qDebug()<<"setting profile "<<profile_.getName();
|
||||||
|
for(CameraSetup& setup : profile_.cameras)
|
||||||
|
{
|
||||||
|
qDebug()<<setup.id;
|
||||||
|
//TODO: dehardcode this
|
||||||
|
setup.remapMap.outputCellSize=200;
|
||||||
|
}
|
||||||
|
invalid_ = false;
|
||||||
if(!profile_.camerasSufficant(cameras_->getCameras()))
|
if(!profile_.camerasSufficant(cameras_->getCameras()))
|
||||||
{
|
{
|
||||||
invalid_ = true;
|
invalid_ = true;
|
||||||
sigInvalidProfile("A camera required for this profile is not available");
|
sigInvalidProfile("A camera required for this profile is not available");
|
||||||
}
|
}
|
||||||
|
statusMsg("set profile " + profile_.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImagePipeline::imageFinished()
|
void ImagePipeline::imageFinished()
|
||||||
@ -65,11 +134,18 @@ void ImagePipeline::imageFinished()
|
|||||||
if(futureImageWatchers_[i]->isFinished())
|
if(futureImageWatchers_[i]->isFinished())
|
||||||
{
|
{
|
||||||
cv::Mat result = futureImageWatchers_[i]->result();
|
cv::Mat result = futureImageWatchers_[i]->result();
|
||||||
|
if(result.data)
|
||||||
|
{
|
||||||
sigResult(Camera::Image(result, 0));
|
sigResult(Camera::Image(result, 0));
|
||||||
delete futureImageWatchers_[i];
|
delete futureImageWatchers_[i];
|
||||||
futureImageWatchers_.erase(futureImageWatchers_.begin()+i);
|
futureImageWatchers_.erase(futureImageWatchers_.begin()+i);
|
||||||
i--;
|
i--;
|
||||||
|
statusMsg("Finished");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sigInvalidProfile("Image pipe failure");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ private slots:
|
|||||||
signals:
|
signals:
|
||||||
void sigInvalidProfile(QString message);
|
void sigInvalidProfile(QString message);
|
||||||
void sigResult(Camera::Image image);
|
void sigResult(Camera::Image image);
|
||||||
|
void statusMsg(QString msg);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setProfile(const Profile& profile);
|
void setProfile(const Profile& profile);
|
||||||
|
27
src/main.cpp
27
src/main.cpp
@ -9,6 +9,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <opencv2/core/mat.hpp>
|
#include <opencv2/core/mat.hpp>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <uvosunwrap/log.h>
|
||||||
|
|
||||||
#include "cameras.h"
|
#include "cameras.h"
|
||||||
#include "./ui/cameradialog.h"
|
#include "./ui/cameradialog.h"
|
||||||
@ -17,6 +18,7 @@
|
|||||||
#include "./ui/profiledialog.h"
|
#include "./ui/profiledialog.h"
|
||||||
#include "imagepipeline.h"
|
#include "imagepipeline.h"
|
||||||
|
|
||||||
|
|
||||||
const char* organziation = "UVOS";
|
const char* organziation = "UVOS";
|
||||||
const char* application = "UVOS";
|
const char* application = "UVOS";
|
||||||
const char* version = "UVOS";
|
const char* version = "UVOS";
|
||||||
@ -44,13 +46,18 @@ void showProfileDialog(Cameras* cameras)
|
|||||||
{
|
{
|
||||||
qDebug()<<__FUNCTION__;
|
qDebug()<<__FUNCTION__;
|
||||||
cameras->stop();
|
cameras->stop();
|
||||||
|
cameras->disable(true);
|
||||||
|
std::vector<cam::Camera::Description> descs = cameras->getCameras();
|
||||||
ProfileDialog diag(cameras);
|
ProfileDialog diag(cameras);
|
||||||
diag.show();
|
diag.show();
|
||||||
diag.exec();
|
diag.exec();
|
||||||
|
cameras->disable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
Log::level = Log::WARN;
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
QCoreApplication::setOrganizationName("UVOS");
|
QCoreApplication::setOrganizationName("UVOS");
|
||||||
QCoreApplication::setOrganizationDomain("uvos.xyz");
|
QCoreApplication::setOrganizationDomain("uvos.xyz");
|
||||||
@ -61,11 +68,12 @@ int main(int argc, char *argv[])
|
|||||||
splash.show();
|
splash.show();
|
||||||
|
|
||||||
QDir().mkpath(Profile::profileLocation());
|
QDir().mkpath(Profile::profileLocation());
|
||||||
QDir().mkpath(CameraSetup::camerasLocation());
|
|
||||||
|
|
||||||
qRegisterMetaType<cv::Mat>("cv::Mat");
|
qRegisterMetaType<cv::Mat>("cv::Mat");
|
||||||
qRegisterMetaType<size_t>("size_t");
|
qRegisterMetaType<size_t>("size_t");
|
||||||
|
qRegisterMetaType<Camera::Image>("Camera::Image");
|
||||||
qRegisterMetaType<Camera::Image>("Image");
|
qRegisterMetaType<Camera::Image>("Image");
|
||||||
|
qRegisterMetaType<std::vector<Camera::Image>>("std::vector<Camera::Image>");
|
||||||
|
|
||||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||||
|
|
||||||
@ -100,11 +108,16 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QObject::connect(&w, &MainWindow::sigEditProfiles, [&cameras, &w](){showProfileDialog(&cameras); w.refreshProfiles();});
|
QObject::connect(&w, &MainWindow::sigEditProfiles, [&cameras, &w](){showProfileDialog(&cameras); w.refreshProfiles();});
|
||||||
QObject::connect(&pipe, &ImagePipeline::sigResult, w.mainImageViewer(), &CvImageViewer::setImage, Qt::QueuedConnection);
|
QObject::connect(&pipe, &ImagePipeline::sigResult, w.mainImageViewer(), &CvImageViewer::setImage, Qt::QueuedConnection);
|
||||||
|
QObject::connect(&pipe, &ImagePipeline::sigInvalidProfile, &w, &MainWindow::profileInconpatible);
|
||||||
|
|
||||||
QObject::connect(&w, &MainWindow::sigProfile, [&pipe](QString name)
|
QObject::connect(&w, &MainWindow::sigProfile, [&pipe](QString name)
|
||||||
{
|
{
|
||||||
Profile profile;
|
Profile profile;
|
||||||
profile.load(name);
|
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);
|
pipe.setProfile(profile);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -122,7 +135,17 @@ int main(int argc, char *argv[])
|
|||||||
cameras.setCameras(showCameraSelectionDialog());
|
cameras.setCameras(showCameraSelectionDialog());
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe.setProfile(w.getProfileName());
|
QString name = w.getProfileName();
|
||||||
|
if(!name.isEmpty())
|
||||||
|
{
|
||||||
|
Profile profile;
|
||||||
|
profile.load(w.getProfileName());
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
int ret = a.exec();
|
int ret = a.exec();
|
||||||
|
|
||||||
|
129
src/profile.cpp
129
src/profile.cpp
@ -6,63 +6,41 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <uvosunwrap/unwrap.h>
|
#include <uvosunwrap/unwrap.h>
|
||||||
|
|
||||||
void CameraSetup::store() const
|
void CameraSetup::store(const QString &filename) const
|
||||||
{
|
{
|
||||||
if(darkmap.data)
|
cv::FileStorage matf(filename.toStdString(), cv::FileStorage::APPEND);
|
||||||
cv::imwrite(darkmapLocation(id).toStdString(), darkmap);
|
|
||||||
if(remapMap.xMat.data)
|
if(remapMap.xMat.data)
|
||||||
saveRemapMap(remapMap, remapMapLocation(id).toStdString());
|
{
|
||||||
|
matf<<("_"+QString::number(id)+"_xmat").toStdString()<<remapMap.xMat<<("_"+QString::number(id)+"_ymat").toStdString()
|
||||||
|
<<remapMap.yMat<<("_"+QString::number(id)+"_origin").toStdString()<<remapMap.topLeftCoordinate;
|
||||||
|
}
|
||||||
|
if(darkmap.data)
|
||||||
|
{
|
||||||
|
matf<<("_"+QString::number(id)+"_darkmap").toStdString()<<darkmap;
|
||||||
|
}
|
||||||
if(bgmask.data)
|
if(bgmask.data)
|
||||||
{
|
{
|
||||||
cv::FileStorage matf(bgmaskLocation(id).toStdString(), cv::FileStorage::WRITE);
|
matf<<("_"+QString::number(id)+"_bgmask").toStdString()<<bgmask;
|
||||||
matf<<"bgmask"<<bgmask;
|
|
||||||
matf.release();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CameraSetup::loadDarkMap(const QString &filename)
|
|
||||||
{
|
|
||||||
darkmap = cv::imread(filename.toStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CameraSetup::loadBgMask(const QString &filename)
|
|
||||||
{
|
|
||||||
cv::FileStorage matf(filename.toStdString(), cv::FileStorage::READ);
|
|
||||||
matf["bgmask"]>>bgmask;
|
|
||||||
matf.release();
|
matf.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraSetup::loadRemapMaps(const QString &filename)
|
void CameraSetup::load(const QString &filename, size_t cameraId)
|
||||||
{
|
|
||||||
remapMap = loadRemapMap(filename.toStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CameraSetup::load(size_t cameraId)
|
|
||||||
{
|
{
|
||||||
id = cameraId;
|
id = cameraId;
|
||||||
loadDarkMap(darkmapLocation(id));
|
cv::FileStorage matf(filename.toStdString(), cv::FileStorage::READ);
|
||||||
loadRemapMaps(remapMapLocation(id));
|
if (matf.isOpened())
|
||||||
loadBgMask(bgmaskLocation(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CameraSetup::camerasLocation()
|
|
||||||
{
|
{
|
||||||
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/cameras/";
|
matf[("_"+QString::number(id)+"_darkmap").toStdString()]>>darkmap;
|
||||||
|
matf[("_"+QString::number(id)+"_bgmask").toStdString()]>>bgmask;
|
||||||
|
matf[("_"+QString::number(id)+"_xmat").toStdString()]>>remapMap.xMat;
|
||||||
|
matf[("_"+QString::number(id)+"_ymat").toStdString()]>>remapMap.yMat;
|
||||||
|
matf[("_"+QString::number(id)+"_origin").toStdString()]>>remapMap.topLeftCoordinate;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
QString CameraSetup::darkmapLocation(size_t cameraId)
|
|
||||||
{
|
{
|
||||||
return camerasLocation() + QString::number(cameraId) + ".darkmap.png";
|
qDebug()<<"could not open file"<<filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CameraSetup::bgmaskLocation(size_t cameraId)
|
|
||||||
{
|
|
||||||
return camerasLocation() + QString::number(cameraId) + "bgmask.mat";
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CameraSetup::remapMapLocation(size_t cameraId)
|
|
||||||
{
|
|
||||||
return camerasLocation() + QString::number(cameraId) + "remap.mat";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightingSetup::store(QSettings& settings) const
|
void LightingSetup::store(QSettings& settings) const
|
||||||
@ -84,6 +62,7 @@ void Profile::store(QSettings& settings) const
|
|||||||
settings.setValue(GROUP + QString("/id"), static_cast<unsigned long long>(id));
|
settings.setValue(GROUP + QString("/id"), static_cast<unsigned long long>(id));
|
||||||
settings.setValue(GROUP + QString("/exposureTime"), exposureTime);
|
settings.setValue(GROUP + QString("/exposureTime"), exposureTime);
|
||||||
settings.setValue(GROUP + QString("/name"), name_);
|
settings.setValue(GROUP + QString("/name"), name_);
|
||||||
|
settings.setValue(GROUP + QString("/nodistort"), nodistort);
|
||||||
|
|
||||||
if(lightmap.data)
|
if(lightmap.data)
|
||||||
cv::imwrite((profileLocation() + QString::number(id) + ".lightmap.png").toStdString(), lightmap);
|
cv::imwrite((profileLocation() + QString::number(id) + ".lightmap.png").toStdString(), lightmap);
|
||||||
@ -93,10 +72,18 @@ void Profile::store(QSettings& settings) const
|
|||||||
{
|
{
|
||||||
const CameraSetup& camera = cameras[i];
|
const CameraSetup& camera = cameras[i];
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
camera.store();
|
camera.store(profileLocation() + name_ + ".profile.mat");
|
||||||
settings.setValue("id", static_cast<unsigned long long>(camera.id));
|
settings.setValue("id", static_cast<unsigned long long>(camera.id));
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
|
|
||||||
|
cv::FileStorage matf((profileLocation() + name_ + ".calcurve.mat").toStdString(), cv::FileStorage::WRITE);
|
||||||
|
matf<<"cal"<<calcurve;
|
||||||
|
matf.release();
|
||||||
|
|
||||||
|
cv::FileStorage matfl((profileLocation() + name_ + ".lightmap.mat").toStdString(), cv::FileStorage::WRITE);
|
||||||
|
matfl<<"cal"<<lightmap;
|
||||||
|
matfl.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profile::load(QSettings &settings)
|
void Profile::load(QSettings &settings)
|
||||||
@ -105,6 +92,7 @@ void Profile::load(QSettings &settings)
|
|||||||
id = settings.value(GROUP + QString("/id")).toULongLong();
|
id = settings.value(GROUP + QString("/id")).toULongLong();
|
||||||
exposureTime = settings.value(GROUP + QString("/exposureTime"), 1.0/60.0).toDouble();
|
exposureTime = settings.value(GROUP + QString("/exposureTime"), 1.0/60.0).toDouble();
|
||||||
name_ = settings.value(GROUP + QString("/name"), "NULL").toString();
|
name_ = settings.value(GROUP + QString("/name"), "NULL").toString();
|
||||||
|
nodistort = settings.value(GROUP + QString("/nodistort"), "NULL").toBool();
|
||||||
|
|
||||||
lightmap = cv::imread((profileLocation() + QString::number(id) + ".lightmap.png").toStdString());
|
lightmap = cv::imread((profileLocation() + QString::number(id) + ".lightmap.png").toStdString());
|
||||||
|
|
||||||
@ -113,9 +101,20 @@ void Profile::load(QSettings &settings)
|
|||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
cameras.push_back(CameraSetup());
|
cameras.push_back(CameraSetup());
|
||||||
cameras.back().load(settings.value("id", 0).toULongLong());
|
cameras.back().load(profileLocation() + name_ + ".profile.mat", settings.value("id", 0).toULongLong());
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
|
|
||||||
|
cv::FileStorage matf((profileLocation() + name_ + ".calcurve.mat").toStdString(), cv::FileStorage::READ);
|
||||||
|
matf["cal"]>>calcurve;
|
||||||
|
matf.release();
|
||||||
|
|
||||||
|
if(calcurve.data && (calcurve.type() != CV_32FC1 || calcurve.rows != 2))
|
||||||
|
calcurve.release();
|
||||||
|
|
||||||
|
cv::FileStorage matfl((profileLocation() + name_ + ".lightmap.mat").toStdString(), cv::FileStorage::READ);
|
||||||
|
matfl["cal"]>>lightmap;
|
||||||
|
matfl.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profile::load(const QString& name)
|
void Profile::load(const QString& name)
|
||||||
@ -164,17 +163,45 @@ QList<QString> Profile::avaiableProfiles()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profile::setCamerasSetupsFromDescription(const std::vector<cam::Camera::Description>& desc)
|
void Profile::setCamerasSetupsFromDescription(const std::vector<cam::Camera::Description>& descs)
|
||||||
{
|
{
|
||||||
cameras.clear();
|
for(size_t i = 0; i < cameras.size(); ++i)
|
||||||
cameras.reserve(desc.size());
|
{
|
||||||
for(size_t i = 0; i < desc.size(); ++i)
|
bool found = false;
|
||||||
|
for(auto& cameraDesc : descs)
|
||||||
|
{
|
||||||
|
if(cameras[i].id == cameraDesc.getId())
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!found)
|
||||||
|
{
|
||||||
|
cameras.erase(cameras.begin()+i);
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(size_t i = 0; i < descs.size(); ++i)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for(auto& camera : cameras)
|
||||||
|
{
|
||||||
|
if(camera.id == descs[i].getId())
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!found)
|
||||||
{
|
{
|
||||||
CameraSetup tmp;
|
CameraSetup tmp;
|
||||||
tmp.load(desc[i].getHash());
|
tmp.load(profileLocation() + name_ + ".profile.mat", descs[i].getId());
|
||||||
cameras.push_back(tmp);
|
cameras.push_back(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Profile::camerasSufficant(const std::vector<cam::Camera::Description>& desc) const
|
bool Profile::camerasSufficant(const std::vector<cam::Camera::Description>& desc) const
|
||||||
{
|
{
|
||||||
@ -184,7 +211,7 @@ bool Profile::camerasSufficant(const std::vector<cam::Camera::Description>& desc
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
for(auto& camera : desc)
|
for(auto& camera : desc)
|
||||||
{
|
{
|
||||||
if(camera.getHash() == cameraProfile.id)
|
if(camera.getId() == cameraProfile.id)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -16,15 +16,8 @@ public:
|
|||||||
RemapMap remapMap;
|
RemapMap remapMap;
|
||||||
cv::Mat darkmap;
|
cv::Mat darkmap;
|
||||||
cv::Mat bgmask;
|
cv::Mat bgmask;
|
||||||
void store() const;
|
void store(const QString& filename) const;
|
||||||
void load(size_t cameraId);
|
void load(const QString& name, size_t cameraId);
|
||||||
void loadBgMask(const QString& filename);
|
|
||||||
void loadDarkMap(const QString& filename);
|
|
||||||
void loadRemapMaps(const QString& filename);
|
|
||||||
static QString camerasLocation();
|
|
||||||
static QString remapMapLocation(size_t cameraId);
|
|
||||||
static QString bgmaskLocation(size_t cameraId);
|
|
||||||
static QString darkmapLocation(size_t cameraId);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LightingSetup
|
class LightingSetup
|
||||||
@ -50,7 +43,9 @@ public:
|
|||||||
LightingSetup lighting;
|
LightingSetup lighting;
|
||||||
double exposureTime = 1.0/60.0;
|
double exposureTime = 1.0/60.0;
|
||||||
cv::Mat lightmap;
|
cv::Mat lightmap;
|
||||||
|
cv::Mat calcurve;
|
||||||
std::vector<CameraSetup> cameras;
|
std::vector<CameraSetup> cameras;
|
||||||
|
bool nodistort = false;
|
||||||
|
|
||||||
Profile(const QString& name = "Unamed");
|
Profile(const QString& name = "Unamed");
|
||||||
void store(QSettings& settings) const;
|
void store(QSettings& settings) const;
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Select Cameras</string>
|
<string>Select Cameras</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../../res/resources.qrc">
|
||||||
|
<normaloff>:/images/icon.png</normaloff>:/images/icon.png</iconset>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
@ -46,7 +50,9 @@
|
|||||||
<header location="global">./src/ui/cameralistwidget.h</header>
|
<header location="global">./src/ui/cameralistwidget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../res/resources.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
|
@ -20,7 +20,7 @@ void CameraListWidget::setConfigured(std::vector<bool> configured)
|
|||||||
setHorizontalHeaderItem(1, new QTableWidgetItem("Configured"));
|
setHorizontalHeaderItem(1, new QTableWidgetItem("Configured"));
|
||||||
for(size_t i = 0; i < desc_.size() && i < configured.size(); ++i)
|
for(size_t i = 0; i < desc_.size() && i < configured.size(); ++i)
|
||||||
{
|
{
|
||||||
setItem(static_cast<int>(i), 1, new QTableWidgetItem("No"));
|
setItem(static_cast<int>(i), 1, new QTableWidgetItem(configured[i] ? "Yes" : "No"));
|
||||||
qDebug()<<"Set item "<<i<<1;
|
qDebug()<<"Set item "<<i<<1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ void CameraListWidget::setCameras(const std::vector<cam::Camera::Description>& d
|
|||||||
setRowCount(static_cast<int>(desc_.size()));
|
setRowCount(static_cast<int>(desc_.size()));
|
||||||
for(size_t i = 0; i < desc_.size(); ++i)
|
for(size_t i = 0; i < desc_.size(); ++i)
|
||||||
{
|
{
|
||||||
setItem(static_cast<int>(i), 0, new QTableWidgetItem((desc_[i].vendor + " " + desc_[i].model).c_str()));
|
setItem(static_cast<int>(i), 0, new QTableWidgetItem((desc_[i].getVendor() + " " + desc_[i].getModel()).c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,20 +7,26 @@
|
|||||||
#include <uvosunwrap/charuco.h>
|
#include <uvosunwrap/charuco.h>
|
||||||
#include <uvosunwrap/unwrap.h>
|
#include <uvosunwrap/unwrap.h>
|
||||||
#include <opencv2/imgproc.hpp>
|
#include <opencv2/imgproc.hpp>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
ConfigureCameraDialog::ConfigureCameraDialog(const CameraSetup& setup, std::shared_ptr<Camera> camera, double exposureTime, QWidget *parent):
|
ConfigureCameraDialog::ConfigureCameraDialog(const CameraSetup& setup, std::shared_ptr<Camera> camera, double exposureTime, QWidget *parent):
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
setup_(setup),
|
setup_(setup),
|
||||||
camera_(camera),
|
camera_(camera),
|
||||||
|
profileExposure_(exposureTime),
|
||||||
ui(new Ui::ConfigureCameraDialog)
|
ui(new Ui::ConfigureCameraDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
qDebug()<<"profileExposure_"<<profileExposure_;
|
||||||
|
ui->doubleSpinBox->setValue(profileExposure_);
|
||||||
|
setExposure(profileExposure_);
|
||||||
|
|
||||||
ui->doubleSpinBox->setValue(exposureTime);
|
uint64_t min, max;
|
||||||
|
camera_->cam()->getExposureTimeLimits(min, max);
|
||||||
|
ui->doubleSpinBox->setMaximum(max/1000000.0);
|
||||||
|
ui->doubleSpinBox->setMinimum(min/1000000.0);
|
||||||
|
|
||||||
connect(ui->pushButtonBgLoad, &QPushButton::clicked, this, &ConfigureCameraDialog::loadBg);
|
connect(ui->doubleSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &ConfigureCameraDialog::setExposure);
|
||||||
connect(ui->pushButtonRemapLoad, &QPushButton::clicked, this, &ConfigureCameraDialog::loadRemap);
|
|
||||||
connect(ui->pushButtonDarkImageLoad, &QPushButton::clicked, this, &ConfigureCameraDialog::loadDark);
|
|
||||||
connect(ui->pushButtonBgClear, &QPushButton::clicked, [this](){setup_.bgmask.release(); checkConfig();});
|
connect(ui->pushButtonBgClear, &QPushButton::clicked, [this](){setup_.bgmask.release(); checkConfig();});
|
||||||
connect(ui->pushButtonRemapClear, &QPushButton::clicked, [this](){setup_.remapMap = RemapMap(); checkConfig();});
|
connect(ui->pushButtonRemapClear, &QPushButton::clicked, [this](){setup_.remapMap = RemapMap(); checkConfig();});
|
||||||
connect(ui->pushButtonDarkImageClear, &QPushButton::clicked, [this](){setup_.darkmap.release(); checkConfig();});
|
connect(ui->pushButtonDarkImageClear, &QPushButton::clicked, [this](){setup_.darkmap.release(); checkConfig();});
|
||||||
@ -38,45 +44,12 @@ ConfigureCameraDialog::~ConfigureCameraDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigureCameraDialog::setExposure(double value)
|
||||||
|
|
||||||
void ConfigureCameraDialog::loadBg()
|
|
||||||
{
|
{
|
||||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open Background Mask"), CameraSetup::camerasLocation(), "OpenCV Mat (*.mat)");
|
if(!camera_->cam()->setExposureTime(value*1000000.0))
|
||||||
if(!filename.isEmpty())
|
QMessageBox::warning(this, "Warning", "Failed to set exposure");
|
||||||
{
|
else
|
||||||
setup_.loadBgMask(filename);
|
qDebug()<<"set exposure to "<<value*1000000.0;
|
||||||
if(!setup_.bgmask.data)
|
|
||||||
QMessageBox::warning(this, "Warning", "Could not load " + filename);
|
|
||||||
checkConfig();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigureCameraDialog::loadRemap()
|
|
||||||
{
|
|
||||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open Background Mask"), CameraSetup::camerasLocation(), "OpenCV Mat (*.mat)");
|
|
||||||
if(!filename.isEmpty())
|
|
||||||
{
|
|
||||||
setup_.loadRemapMaps(filename);
|
|
||||||
if(!setup_.remapMap.xMat.data || !setup_.remapMap.yMat.data)
|
|
||||||
{
|
|
||||||
QMessageBox::warning(this, "Warning", "Could not load " + filename);
|
|
||||||
setup_.remapMap = RemapMap();
|
|
||||||
}
|
|
||||||
checkConfig();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigureCameraDialog::loadDark()
|
|
||||||
{
|
|
||||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open Background Mask"), CameraSetup::camerasLocation(), "Image (*.png)");
|
|
||||||
if(!filename.isEmpty())
|
|
||||||
{
|
|
||||||
setup_.loadDarkMap(filename);
|
|
||||||
if(!setup_.darkmap.data)
|
|
||||||
QMessageBox::warning(this, "Warning", "Could not load " + filename);
|
|
||||||
checkConfig();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureCameraDialog::gotImage(Camera::Image img)
|
void ConfigureCameraDialog::gotImage(Camera::Image img)
|
||||||
@ -109,6 +82,11 @@ void ConfigureCameraDialog::gotImage(Camera::Image img)
|
|||||||
mode_ = MODE_IDLE;
|
mode_ = MODE_IDLE;
|
||||||
break;
|
break;
|
||||||
case MODE_REMAP_GET:
|
case MODE_REMAP_GET:
|
||||||
|
cv::Mat masked;
|
||||||
|
if(setup_.bgmask.data)
|
||||||
|
img.mat.copyTo(masked, setup_.bgmask);
|
||||||
|
else
|
||||||
|
masked = img.mat;
|
||||||
std::vector<DetectedPoint> points = detectCharucoPoints(img.mat, false);
|
std::vector<DetectedPoint> points = detectCharucoPoints(img.mat, false);
|
||||||
if(points.size() < 8)
|
if(points.size() < 8)
|
||||||
{
|
{
|
||||||
@ -117,13 +95,13 @@ void ConfigureCameraDialog::gotImage(Camera::Image img)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
RemapMap map;
|
RemapMap map;
|
||||||
if(createRemapMap(img.mat, map, points))
|
if(createRemapMap(masked, map, points))
|
||||||
setup_.remapMap = map;
|
setup_.remapMap = map;
|
||||||
else
|
else
|
||||||
QMessageBox::warning(this, "Failed", "Error creating map");
|
QMessageBox::warning(this, "Failed", "Error creating map");
|
||||||
for(size_t i = 0; i < points.size(); ++i)
|
for(size_t i = 0; i < points.size(); ++i)
|
||||||
cv::circle(img.mat, points[i].point, 5, cv::Scalar(0,255,0), 1);
|
cv::circle(img.mat, points[i].point, img.mat.cols/50, cv::Scalar(255,255,255), img.mat.cols/200);
|
||||||
ui->widget_4->setImage(Camera::Image(setup_.bgmask, camera_->id()));
|
ui->widget_4->setImage(Camera::Image(img.mat, camera_->id()));
|
||||||
mode_ = MODE_IDLE;
|
mode_ = MODE_IDLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -157,6 +135,8 @@ void ConfigureCameraDialog::captureDark()
|
|||||||
{
|
{
|
||||||
QMessageBox::information(this, "Cover lense", "Please cover the lense of the camera.");
|
QMessageBox::information(this, "Cover lense", "Please cover the lense of the camera.");
|
||||||
mode_ = MODE_DARK_GET;
|
mode_ = MODE_DARK_GET;
|
||||||
|
ui->doubleSpinBox->setValue(profileExposure_);
|
||||||
|
setExposure(profileExposure_);
|
||||||
takeImage();
|
takeImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +145,7 @@ void ConfigureCameraDialog::accept()
|
|||||||
if(checkConfig())
|
if(checkConfig())
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
else
|
else
|
||||||
QMessageBox::warning(this, "Unfinished", "Can not accept unfinished camera setup");
|
QMessageBox::information(this, "Unfinished", "Can not accept unfinished camera setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigureCameraDialog::checkConfig()
|
bool ConfigureCameraDialog::checkConfig()
|
||||||
@ -182,5 +162,5 @@ bool ConfigureCameraDialog::checkConfig()
|
|||||||
ui->ledDark->setLit(darkMapOK);
|
ui->ledDark->setLit(darkMapOK);
|
||||||
ui->ledRemap->setLit(remapMapOk);
|
ui->ledRemap->setLit(remapMapOk);
|
||||||
|
|
||||||
return bgOk && remapMapOk && darkMapOK;
|
return remapMapOk;
|
||||||
}
|
}
|
||||||
|
@ -22,25 +22,27 @@ class ConfigureCameraDialog : public QDialog
|
|||||||
std::shared_ptr<Camera> camera_;
|
std::shared_ptr<Camera> camera_;
|
||||||
int mode_ = MODE_IDLE;
|
int mode_ = MODE_IDLE;
|
||||||
cv::Mat fgImage;
|
cv::Mat fgImage;
|
||||||
|
double profileExposure_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkConfig();
|
bool checkConfig();
|
||||||
void gotImage(Camera::Image img);
|
void gotImage(Camera::Image img);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void loadBg();
|
|
||||||
void loadRemap();
|
|
||||||
void loadDark();
|
|
||||||
void captureBg();
|
void captureBg();
|
||||||
void captureRemap();
|
void captureRemap();
|
||||||
void captureDark();
|
void captureDark();
|
||||||
void takeImage();
|
void takeImage();
|
||||||
|
void setExposure(double value);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void accept() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConfigureCameraDialog(const CameraSetup& setup, const std::shared_ptr<Camera> camera, double exposureTime = 1.0/60, QWidget *parent = nullptr);
|
explicit ConfigureCameraDialog(const CameraSetup& setup, const std::shared_ptr<Camera> camera, double exposureTime = 1.0/60, QWidget *parent = nullptr);
|
||||||
~ConfigureCameraDialog();
|
~ConfigureCameraDialog();
|
||||||
CameraSetup getCameraSetup(){return setup_;}
|
CameraSetup getCameraSetup(){return setup_;}
|
||||||
void accept() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ConfigureCameraDialog *ui;
|
Ui::ConfigureCameraDialog *ui;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>466</width>
|
<width>545</width>
|
||||||
<height>438</height>
|
<height>614</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -31,6 +31,29 @@
|
|||||||
<property name="horizontalSpacing">
|
<property name="horizontalSpacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="Led" name="ledBg" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="3">
|
||||||
|
<widget class="QPushButton" name="pushButtonBgCreate">
|
||||||
|
<property name="text">
|
||||||
|
<string>Create</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -48,13 +71,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Background image</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="3">
|
<item row="2" column="3">
|
||||||
<widget class="QPushButton" name="pushButtonDarkImageCreate">
|
<widget class="QPushButton" name="pushButtonDarkImageCreate">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -62,32 +78,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="4">
|
|
||||||
<widget class="QPushButton" name="pushButtonBgClear">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Clear</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="Led" name="ledRemap" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="4">
|
<item row="1" column="4">
|
||||||
<widget class="QPushButton" name="pushButtonRemapClear">
|
<widget class="QPushButton" name="pushButtonRemapClear">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@ -98,57 +88,40 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3">
|
<item row="3" column="0">
|
||||||
<widget class="QPushButton" name="pushButtonBgCreate">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Create</string>
|
<string>Background image</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="2" column="2">
|
||||||
<widget class="Led" name="ledBg" native="true"/>
|
<widget class="QPushButton" name="pushButtonDarkImageShow">
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Remap Map</string>
|
<string>Show</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="1">
|
||||||
<widget class="QPushButton" name="pushButtonRemapLoad">
|
<widget class="Led" name="ledRemap" native="true">
|
||||||
<property name="text">
|
|
||||||
<string>Load</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="2">
|
|
||||||
<widget class="QPushButton" name="pushButtonBgLoad">
|
|
||||||
<property name="text">
|
|
||||||
<string>Load</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="Led" name="ledDark" native="true">
|
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>40</width>
|
||||||
<height>0</height>
|
<height>40</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="3" column="2">
|
||||||
<widget class="QPushButton" name="pushButtonDarkImageLoad">
|
<widget class="QPushButton" name="pushButtonBgShow">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Load</string>
|
<string>Show</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -159,10 +132,36 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="Led" name="ledDark" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>Remap Map (required)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="4">
|
||||||
|
<widget class="QPushButton" name="pushButtonBgClear">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -182,11 +181,14 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBox">
|
<widget class="QDoubleSpinBox" name="doubleSpinBox">
|
||||||
|
<property name="decimals">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>1.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="singleStep">
|
<property name="singleStep">
|
||||||
<double>0.100000000000000</double>
|
<double>0.001000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -219,18 +221,18 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>Led</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">./src/ui/led.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>CvImageViewer</class>
|
<class>CvImageViewer</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header location="global">./src/ui/cvimageviewer.h</header>
|
<header location="global">./src/ui/cvimageviewer.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>Led</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header location="global">./src/ui/led.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
@ -1,21 +1,60 @@
|
|||||||
#include "cvimageviewer.h"
|
#include "cvimageviewer.h"
|
||||||
#include <QPicture>
|
#include <QPicture>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <opencv2/imgcodecs.hpp>
|
||||||
|
|
||||||
CvImageViewer::CvImageViewer(QWidget *parent, size_t lastId) :
|
CvImageViewer::CvImageViewer(QWidget *parent, size_t lastId) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
lastId_(lastId)
|
lastId_(lastId),
|
||||||
|
saveAction_("Save Image", nullptr)
|
||||||
{
|
{
|
||||||
|
connect(&saveAction_, &QAction::triggered, this, &CvImageViewer::saveImage);
|
||||||
qimage_.load(":/images/noimage.png");
|
qimage_.load(":/images/noimage.png");
|
||||||
|
|
||||||
|
imageContextMenu_.addAction(&saveAction_);
|
||||||
}
|
}
|
||||||
|
|
||||||
CvImageViewer::~CvImageViewer()
|
CvImageViewer::~CvImageViewer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CvImageViewer::saveImage()
|
||||||
|
{
|
||||||
|
QString fileName;
|
||||||
|
if(origImage_.type() == CV_8UC3 || origImage_.type() == CV_8SC3 || origImage_.type() == CV_8UC1 || origImage_.type() == CV_8SC1)
|
||||||
|
{
|
||||||
|
fileName = QFileDialog::getSaveFileName(this, "Save Image", "./", "*.mat *.png" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fileName = QFileDialog::getSaveFileName(this, "Save Image", "./", "*.mat" );
|
||||||
|
}
|
||||||
|
if(!fileName.isEmpty())
|
||||||
|
{
|
||||||
|
QStringList tokens = fileName.split('.');
|
||||||
|
if(tokens.back() != "mat" && tokens.back() != "png")
|
||||||
|
fileName.append(".mat");
|
||||||
|
tokens = fileName.split('.');
|
||||||
|
if(tokens.back() == "png")
|
||||||
|
{
|
||||||
|
imwrite(fileName.toStdString(), origImage_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cv::FileStorage matf(fileName.toStdString(), cv::FileStorage::WRITE);
|
||||||
|
matf<<"image"<<origImage_;
|
||||||
|
matf.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CvImageViewer::setImage(Camera::Image img)
|
void CvImageViewer::setImage(Camera::Image img)
|
||||||
{
|
{
|
||||||
image_ = img.mat;
|
image_ = img.mat;
|
||||||
|
origImage_=img.mat;
|
||||||
|
qDebug()<<"viwer got"<<image_.rows<<'x'<<image_.cols<<" type "<<image_.type()<<"image from camera"<<img.cameraId;
|
||||||
if(image_.type() == CV_8UC3 || image_.type() == CV_8SC3)
|
if(image_.type() == CV_8UC3 || image_.type() == CV_8SC3)
|
||||||
{
|
{
|
||||||
qimage_ = QImage(image_.data, image_.cols, image_.rows, image_.step, QImage::Format_RGB888);
|
qimage_ = QImage(image_.data, image_.cols, image_.rows, image_.step, QImage::Format_RGB888);
|
||||||
@ -37,19 +76,41 @@ void CvImageViewer::setImage(Camera::Image img)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CvImageViewer::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button() == Qt::RightButton)
|
||||||
|
{
|
||||||
|
saveAction_.setEnabled(origImage_.data);
|
||||||
|
imageContextMenu_.popup(event->globalPos());
|
||||||
|
}
|
||||||
|
else if(origImage_.data && event->x() > imgrect_.x() && event->y() > imgrect_.y() && event->x() < imgrect_.x()+imgrect_.width() && event->y() < imgrect_.y()+imgrect_.height())
|
||||||
|
{
|
||||||
|
int x = (event->x()-imgrect_.x())/static_cast<double>(imgrect_.width())*origImage_.cols;
|
||||||
|
int y = (event->y()-imgrect_.y())/static_cast<double>(imgrect_.height())*origImage_.rows;
|
||||||
|
qDebug()<<x<<y;
|
||||||
|
if(origImage_.type() == CV_32FC1)
|
||||||
|
{
|
||||||
|
if(x >= 0 && y >= 0 && x <= origImage_.cols && y < origImage_.rows)
|
||||||
|
sigValue(x, y, origImage_.at<float>(y,x));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
sigValue(x, y, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QWidget::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void CvImageViewer::paintEvent(QPaintEvent* event)
|
void CvImageViewer::paintEvent(QPaintEvent* event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
if(!fixedOnWidth_)
|
double ratio = qimage_.size().height() / (double)qimage_.size().width();
|
||||||
{
|
if(rect().width()*ratio <= rect().height())
|
||||||
double ratio = qimage_.size().width() / qimage_.size().height();
|
imgrect_.setRect(0, (rect().height()-rect().width()*ratio)/2, rect().width(), rect().width()*ratio);
|
||||||
painter.drawImage(QRect((rect().width()-rect().height())/2, rect().y(), rect().height()*ratio, rect().height()), qimage_);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
imgrect_.setRect((rect().width()-rect().height()/ratio)/2, 0, rect().height()/ratio, rect().height());
|
||||||
double ratio = qimage_.size().height() / qimage_.size().width();
|
painter.drawImage(imgrect_, qimage_);
|
||||||
painter.drawImage(QRect(rect().x(), (rect().height()-rect().width())/2, rect().width(), rect().width()*ratio), qimage_);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,19 +3,32 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QMenu>
|
||||||
#include "../cameras.h"
|
#include "../cameras.h"
|
||||||
|
|
||||||
class CvImageViewer : public QWidget
|
class CvImageViewer : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
cv::Mat origImage_;
|
||||||
cv::Mat image_;
|
cv::Mat image_;
|
||||||
QImage qimage_;
|
QImage qimage_;
|
||||||
bool fixedOnWidth_ = false;
|
bool fixedOnWidth_ = false;
|
||||||
size_t lastId_;
|
size_t lastId_;
|
||||||
|
QMenu imageContextMenu_;
|
||||||
|
QAction saveAction_;
|
||||||
|
QRect imgrect_;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void saveImage();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent(QPaintEvent* event) override;
|
virtual void paintEvent(QPaintEvent* event) override;
|
||||||
|
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sigValue(size_t x, size_t y, double value);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setImage(Camera::Image img);
|
void setImage(Camera::Image img);
|
||||||
@ -23,6 +36,8 @@ public slots:
|
|||||||
public:
|
public:
|
||||||
explicit CvImageViewer(QWidget *parent = nullptr, size_t lastId = 0);
|
explicit CvImageViewer(QWidget *parent = nullptr, size_t lastId = 0);
|
||||||
void setFixedOnWidth(bool in){fixedOnWidth_ = in;}
|
void setFixedOnWidth(bool in){fixedOnWidth_ = in;}
|
||||||
|
cv::Mat getImage(){return origImage_;}
|
||||||
|
|
||||||
size_t lastId(){return lastId_;}
|
size_t lastId(){return lastId_;}
|
||||||
~CvImageViewer();
|
~CvImageViewer();
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include "ui_editprofiledialog.h"
|
#include "ui_editprofiledialog.h"
|
||||||
#include <uvosled.h>
|
#include <uvosled.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include "configurecameradialog.h"
|
#include "configurecameradialog.h"
|
||||||
|
|
||||||
@ -24,26 +26,91 @@ EditProfileDialog::EditProfileDialog(Cameras* cameras, const Profile profile, QW
|
|||||||
ui->checkBoxCh3->setChecked(profile_.lighting.mask & CHANNEL_C);
|
ui->checkBoxCh3->setChecked(profile_.lighting.mask & CHANNEL_C);
|
||||||
ui->checkBoxCh4->setChecked(profile_.lighting.mask & CHANNEL_D);
|
ui->checkBoxCh4->setChecked(profile_.lighting.mask & CHANNEL_D);
|
||||||
|
|
||||||
if(profile_.cameras.size() == 0)
|
ui->checkBoxNodistort->setChecked(profile_.nodistort);
|
||||||
profile_.setCamerasSetupsFromDescription(cameras_->getCameras());
|
|
||||||
|
std::vector<cam::Camera::Description> descs = cameras_->getCameras();
|
||||||
|
profile_.setCamerasSetupsFromDescription(descs);
|
||||||
|
|
||||||
|
if(profile_.cameras.size() > 0)
|
||||||
|
{
|
||||||
|
uint64_t min, max;
|
||||||
|
std::shared_ptr<Camera> cam = cameras_->getCamera(profile_.cameras[0].id);
|
||||||
|
if(cam)
|
||||||
|
{
|
||||||
|
cam->cam()->getExposureTimeLimits(min, max);
|
||||||
|
ui->doubleSpinBoxExposure->setMaximum(max/1000000.0);
|
||||||
|
ui->doubleSpinBoxExposure->setMinimum(min/1000000.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->calLed->setLit(profile_.calcurve.data);
|
||||||
|
|
||||||
connect(ui->doubleSpinBoxBrightness, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double in){profile_.lighting.brightness = in/100.0;});
|
connect(ui->doubleSpinBoxBrightness, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double in){profile_.lighting.brightness = in/100.0;});
|
||||||
connect(ui->doubleSpinBoxExposure, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double in){profile_.exposureTime = in;});
|
connect(ui->doubleSpinBoxExposure, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double in){profile_.exposureTime = in; invalidateCameras();});
|
||||||
connect(ui->lineEditName, &QLineEdit::textChanged, [this](QString in){profile_.setName(in);});
|
connect(ui->lineEditName, &QLineEdit::textChanged, [this](QString in){profile_.setName(in);});
|
||||||
connect(ui->checkBoxCh1, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
connect(ui->checkBoxCh1, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
||||||
connect(ui->checkBoxCh2, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
connect(ui->checkBoxCh2, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
||||||
connect(ui->checkBoxCh3, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
connect(ui->checkBoxCh3, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
||||||
connect(ui->checkBoxCh4, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
connect(ui->checkBoxCh4, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
||||||
connect(ui->pushButton, &QPushButton::clicked, this, &EditProfileDialog::configureCamera);
|
connect(ui->pushButton, &QPushButton::clicked, this, &EditProfileDialog::configureCamera);
|
||||||
|
connect(ui->checkBoxNodistort, &QCheckBox::stateChanged, [this](int state){profile_.nodistort = state == Qt::Checked ?: false; setConfigured();});
|
||||||
|
connect(ui->pushButtonCalLoad, &QPushButton::clicked, this, &EditProfileDialog::loadCalcurve);
|
||||||
|
connect(ui->pushButtonLightmapLoad, &QPushButton::clicked, this, &EditProfileDialog::loadCalcurve);
|
||||||
ui->listView->setCameras(cameras_->getCameras());
|
ui->listView->setCameras(cameras_->getCameras());
|
||||||
ui->listView->setSelectionMode(QAbstractItemView::SingleSelection);
|
ui->listView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
setConfigured();
|
setConfigured();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditProfileDialog::setConfigured()
|
void EditProfileDialog::loadLightmap()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(this, "Open Lightmap", "./", "*.mat");
|
||||||
|
if(!fileName.isEmpty())
|
||||||
|
{
|
||||||
|
profile_.calcurve.release();
|
||||||
|
cv::FileStorage matf(fileName.toStdString(), cv::FileStorage::READ);
|
||||||
|
matf["image"]>>profile_.lightmap;
|
||||||
|
|
||||||
|
if(matf.isOpened() && (!profile_.calcurve.data || profile_.calcurve.type() != CV_32FC1))
|
||||||
|
{
|
||||||
|
profile_.lightmap.release();
|
||||||
|
QMessageBox::warning(this, "Invalid file", "File selected dose not contain a valid lightmap");
|
||||||
|
}
|
||||||
|
else if(!profile_.calcurve.data)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "Can no open", "Can not open file selected");
|
||||||
|
}
|
||||||
|
matf.release();
|
||||||
|
ui->ledLightmap->setLit(profile_.lightmap.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditProfileDialog::loadCalcurve()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(this, "Open Cal Curve", "./", "*.mat");
|
||||||
|
if(!fileName.isEmpty())
|
||||||
|
{
|
||||||
|
profile_.calcurve.release();
|
||||||
|
cv::FileStorage matf(fileName.toStdString(), cv::FileStorage::READ);
|
||||||
|
matf["cal"]>>profile_.calcurve;
|
||||||
|
|
||||||
|
if(matf.isOpened() && (!profile_.calcurve.data || profile_.calcurve.type() != CV_32FC1 || profile_.calcurve.rows != 2))
|
||||||
|
{
|
||||||
|
profile_.calcurve.release();
|
||||||
|
QMessageBox::warning(this, "Invalid file", "File selected dose not contain a valid cal curve");
|
||||||
|
}
|
||||||
|
else if(!profile_.calcurve.data)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "Can no open", "Can not open file selected");
|
||||||
|
}
|
||||||
|
matf.release();
|
||||||
|
ui->calLed->setLit(profile_.calcurve.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EditProfileDialog::setConfigured()
|
||||||
{
|
{
|
||||||
std::vector<cam::Camera::Description> descs = cameras_->getCameras();
|
std::vector<cam::Camera::Description> descs = cameras_->getCameras();
|
||||||
std::vector<bool> configured(descs.size(), false);
|
std::vector<bool> configured(descs.size(), profile_.nodistort);
|
||||||
|
|
||||||
for(size_t i = 0; i< profile_.cameras.size(); ++i)
|
for(size_t i = 0; i< profile_.cameras.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -52,12 +119,19 @@ void EditProfileDialog::setConfigured()
|
|||||||
{
|
{
|
||||||
for(auto& camera : descs)
|
for(auto& camera : descs)
|
||||||
{
|
{
|
||||||
if(camera.getHash() == profileCamera.id)
|
if(camera.getId() == profileCamera.id)
|
||||||
configured[i] = true;
|
configured[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->listView->setConfigured(configured);
|
ui->listView->setConfigured(configured);
|
||||||
|
bool fullyConfigured = true;
|
||||||
|
for(bool config : configured)
|
||||||
|
{
|
||||||
|
if(!config)
|
||||||
|
fullyConfigured = false;
|
||||||
|
}
|
||||||
|
return fullyConfigured;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditProfileDialog::invalidateCameras()
|
void EditProfileDialog::invalidateCameras()
|
||||||
@ -78,10 +152,12 @@ void EditProfileDialog::configureCamera()
|
|||||||
qDebug()<<"descs"<<descs.size();
|
qDebug()<<"descs"<<descs.size();
|
||||||
if(!descs.empty())
|
if(!descs.empty())
|
||||||
{
|
{
|
||||||
|
qDebug()<<"want to edit id"<<descs[0].getId();
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for(; i < profile_.cameras.size(); ++i)
|
for(; i < profile_.cameras.size(); ++i)
|
||||||
{
|
{
|
||||||
if(profile_.cameras[i].id == descs[0].getHash())
|
qDebug()<<"test"<<profile_.cameras[i].id ;
|
||||||
|
if(profile_.cameras[i].id == descs[0].getId())
|
||||||
{
|
{
|
||||||
std::shared_ptr<Camera> camera = cameras_->getCamera(profile_.cameras[i].id);
|
std::shared_ptr<Camera> camera = cameras_->getCamera(profile_.cameras[i].id);
|
||||||
if(camera)
|
if(camera)
|
||||||
@ -94,9 +170,18 @@ void EditProfileDialog::configureCamera()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setConfigured();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditProfileDialog::accept()
|
||||||
|
{
|
||||||
|
if(!setConfigured())
|
||||||
|
QMessageBox::information(this, "Unfinished", "Can not accept with unconfigured cameras");
|
||||||
|
else
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
void EditProfileDialog::setMask()
|
void EditProfileDialog::setMask()
|
||||||
{
|
{
|
||||||
uint8_t mask = (ui->checkBoxCh1->isChecked() ? CHANNEL_A : 0) |
|
uint8_t mask = (ui->checkBoxCh1->isChecked() ? CHANNEL_A : 0) |
|
||||||
|
@ -15,13 +15,17 @@ class EditProfileDialog : public QDialog
|
|||||||
Profile profile_;
|
Profile profile_;
|
||||||
Cameras* cameras_;
|
Cameras* cameras_;
|
||||||
|
|
||||||
void setConfigured();
|
bool setConfigured();
|
||||||
void invalidateCameras();
|
void invalidateCameras();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void setMask();
|
void setMask();
|
||||||
void configureCamera();
|
void configureCamera();
|
||||||
|
void loadCalcurve();
|
||||||
|
void loadLightmap();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void accept() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EditProfileDialog(Cameras* cameras, const Profile profile = Profile(), QWidget *parent = nullptr);
|
explicit EditProfileDialog(Cameras* cameras, const Profile profile = Profile(), QWidget *parent = nullptr);
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>539</width>
|
<width>539</width>
|
||||||
<height>485</height>
|
<height>652</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Profile</string>
|
<string>Edit Profile</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
@ -153,6 +153,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxExposure">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxExposure">
|
||||||
|
<property name="decimals">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>1.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
@ -176,9 +179,89 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxNodistort">
|
||||||
|
<property name="text">
|
||||||
|
<string>Don't undisort camera image </string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Calibration curve:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="Led" name="calLed" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="pushButtonCalLoad">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Load</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_8">
|
||||||
|
<property name="text">
|
||||||
|
<string>Lightmap:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="Led" name="ledLightmap" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QPushButton" name="pushButtonLightmapLoad">
|
||||||
|
<property name="text">
|
||||||
|
<string>Load</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -192,6 +275,12 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>Led</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header location="global">./src/ui/led.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>CameraListWidget</class>
|
<class>CameraListWidget</class>
|
||||||
<extends>QListView</extends>
|
<extends>QListView</extends>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <uvosled.h>
|
#include <uvosled.h>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include "../profile.h"
|
#include "../profile.h"
|
||||||
|
|
||||||
@ -17,9 +18,62 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
connect(ui->actionProfile, &QAction::triggered, [this](bool checked){(void)checked; sigEditProfiles();});
|
connect(ui->actionProfile, &QAction::triggered, [this](bool checked){(void)checked; sigEditProfiles();});
|
||||||
connect(ui->comboBox, &QComboBox::currentTextChanged, this, &MainWindow::sigProfile);
|
connect(ui->comboBox, &QComboBox::currentTextChanged, this, &MainWindow::sigProfile);
|
||||||
connect(ui->pushButtonCapture, &QPushButton::clicked, this, &MainWindow::sigCapture);
|
connect(ui->pushButtonCapture, &QPushButton::clicked, this, &MainWindow::sigCapture);
|
||||||
|
connect(ui->mainViewer, &CvImageViewer::sigValue, this, &MainWindow::setImageValue);
|
||||||
|
connect(ui->actionOpen, &QAction::triggered, [this](bool checked){(void)checked; openImage();});
|
||||||
|
connect(ui->actionSave_2, &QAction::triggered, [this](bool checked){(void)checked; saveImage();});
|
||||||
refreshProfiles();
|
refreshProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setImageValue(size_t x, size_t y, double value)
|
||||||
|
{
|
||||||
|
ui->lcdNumber_3->display((double)x);
|
||||||
|
ui->lcdNumber_2->display((double)y);
|
||||||
|
ui->lcdNumber->display(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::saveImage()
|
||||||
|
{
|
||||||
|
if(!ui->mainViewer->getImage().data)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "No image", "There is no image to save");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(this, "Save Image", "./", "*.mat");
|
||||||
|
if(!fileName.isEmpty())
|
||||||
|
{
|
||||||
|
QStringList tokens = fileName.split('.');
|
||||||
|
if(tokens.back() != "mat")
|
||||||
|
fileName.append(".mat");
|
||||||
|
cv::FileStorage matf(fileName.toStdString(), cv::FileStorage::WRITE);
|
||||||
|
matf<<"image"<<ui->mainViewer->getImage();
|
||||||
|
matf.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::openImage()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(this, "Open Image", "./", "*.mat");
|
||||||
|
if(!fileName.isEmpty())
|
||||||
|
{
|
||||||
|
cv::Mat image;
|
||||||
|
cv::FileStorage matf(fileName.toStdString(), cv::FileStorage::READ);
|
||||||
|
matf["image"]>>image;
|
||||||
|
|
||||||
|
if(matf.isOpened() && (!image.data || image.type() != CV_32FC1))
|
||||||
|
{
|
||||||
|
image.release();
|
||||||
|
QMessageBox::warning(this, "Invalid file", "File selected dose not contain a valid lightmap");
|
||||||
|
}
|
||||||
|
else if(!image.data)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "Can no open", "Can not open file selected");
|
||||||
|
}
|
||||||
|
matf.release();
|
||||||
|
ui->mainViewer->setImage(Camera::Image(image, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::addCamera(std::shared_ptr<Camera> camera)
|
void MainWindow::addCamera(std::shared_ptr<Camera> camera)
|
||||||
{
|
{
|
||||||
viewers_.push_back(new CvImageViewer(this, camera->id()));
|
viewers_.push_back(new CvImageViewer(this, camera->id()));
|
||||||
@ -28,6 +82,11 @@ void MainWindow::addCamera(std::shared_ptr<Camera> camera)
|
|||||||
ui->viewerLayout->addWidget(viewers_.back());
|
ui->viewerLayout->addWidget(viewers_.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::statusMsg(QString msg)
|
||||||
|
{
|
||||||
|
ui->statusbar->showMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::removeCamera(std::shared_ptr<Camera> camera)
|
void MainWindow::removeCamera(std::shared_ptr<Camera> camera)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < viewers_.size(); ++i)
|
for(size_t i = 0; i < viewers_.size(); ++i)
|
||||||
@ -93,4 +152,3 @@ MainWindow::~MainWindow()
|
|||||||
delete viewer;
|
delete viewer;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,11 @@ class MainWindow : public QMainWindow
|
|||||||
private:
|
private:
|
||||||
std::vector<CvImageViewer*> viewers_;
|
std::vector<CvImageViewer*> viewers_;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void setImageValue(size_t x, size_t y, double value);
|
||||||
|
void saveImage();
|
||||||
|
void openImage();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sigCapture();
|
void sigCapture();
|
||||||
void sigProfile(QString profileName);
|
void sigProfile(QString profileName);
|
||||||
@ -30,6 +35,7 @@ public slots:
|
|||||||
void removeCamera(std::shared_ptr<Camera> camera);
|
void removeCamera(std::shared_ptr<Camera> camera);
|
||||||
bool setProfile(const QString& profileName);
|
bool setProfile(const QString& profileName);
|
||||||
QString getProfileName();
|
QString getProfileName();
|
||||||
|
void statusMsg(QString msg);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
|
@ -11,7 +11,11 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>Lubricant Detector</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../../res/resources.qrc">
|
||||||
|
<normaloff>:/images/icon.png</normaloff>:/images/icon.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
@ -27,6 +31,9 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
|
</property>
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -68,7 +75,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>467</width>
|
<width>467</width>
|
||||||
<height>353</height>
|
<height>313</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
@ -79,6 +86,55 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="layoutDirection">
|
||||||
|
<enum>Qt::LeftToRight</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>X</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLCDNumber" name="lcdNumber_3"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLCDNumber" name="lcdNumber_2"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Value</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLCDNumber" name="lcdNumber"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -146,7 +202,8 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>File</string>
|
<string>File</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionSave"/>
|
<addaction name="actionOpen"/>
|
||||||
|
<addaction name="actionSave_2"/>
|
||||||
<addaction name="actionQuit"/>
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuSetup">
|
<widget class="QMenu" name="menuSetup">
|
||||||
@ -164,6 +221,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Quit</string>
|
<string>Quit</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+Q</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionCameras">
|
<action name="actionCameras">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -180,6 +240,22 @@
|
|||||||
<string>Save</string>
|
<string>Save</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionSave_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+S</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionOpen">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+O</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
@ -189,6 +265,8 @@
|
|||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../res/resources.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -34,7 +34,7 @@ void ProfileDialog::editProfile()
|
|||||||
QMessageBox::critical(this, "Profile Incompatible", "Not all cameras need for this profile are available");
|
QMessageBox::critical(this, "Profile Incompatible", "Not all cameras need for this profile are available");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EditProfileDialog dialog(cameras_, profile);
|
EditProfileDialog dialog(cameras_, profile, this);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
int ret = dialog.exec();
|
int ret = dialog.exec();
|
||||||
if(ret == QDialog::Accepted)
|
if(ret == QDialog::Accepted)
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Profiles</string>
|
<string>Profiles</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../../res/resources.qrc">
|
||||||
|
<normaloff>:/images/icon.png</normaloff>:/images/icon.png</iconset>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
@ -61,7 +65,9 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../res/resources.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
|
Reference in New Issue
Block a user