mainny ui improcements
This commit is contained in:
parent
50777fe056
commit
86ec50575b
25 changed files with 819 additions and 264 deletions
|
|
@ -1,37 +1,96 @@
|
|||
#include "imagepipeline.h"
|
||||
#include <uvosunwrap/unwrap.h>
|
||||
#include <uvosunwrap/normalize.h>
|
||||
#include <uvosunwrap/curve.h>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
#include <QFuture>
|
||||
#include <QDebug>
|
||||
|
||||
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)
|
||||
{
|
||||
qDebug()<<__FUNCTION__<<"got"<<images.size()<<"images";
|
||||
std::vector<RemapedImage> remapedImages;
|
||||
remapedImages.reserve(images.size());
|
||||
|
||||
for(Camera::Image& image : images)
|
||||
try
|
||||
{
|
||||
for(auto& camera : profile.cameras)
|
||||
if(profile.nodistort && images.size() > 0)
|
||||
{
|
||||
if(camera.id == image.cameraId)
|
||||
for(auto& image : images)
|
||||
{
|
||||
if(camera.darkmap.data)
|
||||
image.mat = image.mat - camera.darkmap;
|
||||
remapedImages.push_back(applyRemap(image.mat, camera.remapMap));
|
||||
break;
|
||||
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)
|
||||
{
|
||||
qDebug()<<__FUNCTION__<<"image cam id"<<image.cameraId;
|
||||
bool matched = false;
|
||||
for(auto& camera : profile.cameras)
|
||||
{
|
||||
if(camera.id == image.cameraId)
|
||||
{
|
||||
if(camera.darkmap.data)
|
||||
{
|
||||
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));
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!matched)
|
||||
qWarning()<<"non matching image recived";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(cv::Exception ex)
|
||||
{
|
||||
qDebug()<<ex.err.c_str();
|
||||
qDebug()<<"Image pipe failure";
|
||||
return cv::Mat();
|
||||
}
|
||||
|
||||
cv::Mat output = simpleStich(remapedImages);
|
||||
output.convertTo(output, CV_32FC1, 1.0/255.0, 0);
|
||||
if(remapedImages.size() > 0)
|
||||
{
|
||||
cv::Mat output = simpleStich(remapedImages);
|
||||
output.convertTo(output, CV_32FC1, 1.0/255.0, 0);
|
||||
|
||||
if(profile.lightmap.data)
|
||||
normalize(output, profile.lightmap);
|
||||
return output;
|
||||
if(profile.lightmap.data)
|
||||
normalize(output, profile.lightmap);
|
||||
|
||||
if(profile.calcurve.data)
|
||||
applyCurve(output, profile.calcurve);
|
||||
return output;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Image pipe failure insufficant matched images";
|
||||
return cv::Mat();
|
||||
}
|
||||
}
|
||||
|
||||
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>());
|
||||
connect(futureImageWatchers_.back(), &QFutureWatcher<cv::Mat>::finished, this, &ImagePipeline::imageFinished);
|
||||
|
||||
statusMsg("Processing");
|
||||
QFuture<cv::Mat> futureImage = QtConcurrent::run(&ImagePipeline::process, profile_, images);
|
||||
futureImageWatchers_.back()->setFuture(futureImage);
|
||||
}
|
||||
|
|
@ -51,11 +111,20 @@ void ImagePipeline::setProfile(const Profile& profile)
|
|||
profile_ = profile;
|
||||
cameras_->setExposureTime(profile_.exposureTime);
|
||||
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()))
|
||||
{
|
||||
invalid_ = true;
|
||||
sigInvalidProfile("A camera required for this profile is not available");
|
||||
}
|
||||
statusMsg("set profile " + profile_.getName());
|
||||
}
|
||||
|
||||
void ImagePipeline::imageFinished()
|
||||
|
|
@ -65,11 +134,18 @@ void ImagePipeline::imageFinished()
|
|||
if(futureImageWatchers_[i]->isFinished())
|
||||
{
|
||||
cv::Mat result = futureImageWatchers_[i]->result();
|
||||
sigResult(Camera::Image(result, 0));
|
||||
delete futureImageWatchers_[i];
|
||||
futureImageWatchers_.erase(futureImageWatchers_.begin()+i);
|
||||
i--;
|
||||
if(result.data)
|
||||
{
|
||||
sigResult(Camera::Image(result, 0));
|
||||
delete futureImageWatchers_[i];
|
||||
futureImageWatchers_.erase(futureImageWatchers_.begin()+i);
|
||||
i--;
|
||||
statusMsg("Finished");
|
||||
}
|
||||
else
|
||||
{
|
||||
sigInvalidProfile("Image pipe failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue