fix various bugs
add commandline parser for various options allow cameras to be operated in serial fashion allow disabeling of quirks allow changing of Photonfocus quirk timeings
This commit is contained in:
parent
3a77df6dd5
commit
b9b4b0fc2a
10 changed files with 134 additions and 36 deletions
|
|
@ -8,12 +8,41 @@
|
|||
#include <algorithm>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
ImagePipeline::ImagePipeline(Cameras* cameras, QObject *parent): QObject(parent), cameras_(cameras)
|
||||
ImagePipeline::ImagePipeline(Cameras* cameras, bool simpleStichingAlg, QObject *parent):
|
||||
QObject(parent), cameras_(cameras), simpleStichingAlg_(simpleStichingAlg)
|
||||
{
|
||||
connect(cameras_, &Cameras::newImages, this, &ImagePipeline::apply);
|
||||
}
|
||||
|
||||
cv::Mat ImagePipeline::process(const Profile profile, std::vector<Camera::Image> images)
|
||||
void ImagePipeline::applyDarkMap(cv::Mat& image, const cv::Mat& darkmap)
|
||||
{
|
||||
cv::Mat localDarkMap;
|
||||
if(image.size() != darkmap.size())
|
||||
{
|
||||
qWarning()<<"image and darkmap not of the same size"<<image.size().height<<'x'<<image.size().width<<darkmap.size().height<<'x'<<darkmap.size().width;
|
||||
return;
|
||||
}
|
||||
else if(image.channels() != darkmap.channels())
|
||||
{
|
||||
qWarning()<<"image and darkmap do not have the same number of channels";
|
||||
if(image.channels() == 1 && darkmap.channels() == 3)
|
||||
cv::cvtColor(darkmap, localDarkMap, cv::COLOR_BGR2GRAY);
|
||||
else if(image.channels() == 3 && darkmap.channels() == 1)
|
||||
cv::cvtColor(darkmap, localDarkMap, cv::COLOR_GRAY2BGR);
|
||||
else
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
localDarkMap = darkmap;
|
||||
}
|
||||
cv::Mat subtracted;
|
||||
image.copyTo(subtracted);
|
||||
subtracted = image - localDarkMap;
|
||||
image = subtracted;
|
||||
}
|
||||
|
||||
cv::Mat ImagePipeline::process(const Profile profile, std::vector<Camera::Image> images, bool simpleStichingAlg)
|
||||
{
|
||||
qDebug()<<__func__<<"got"<<images.size()<<"images";
|
||||
std::vector<RemapedImage> remapedImages;
|
||||
|
|
@ -32,7 +61,7 @@ cv::Mat ImagePipeline::process(const Profile profile, std::vector<Camera::Image>
|
|||
img.origin.y = 0;
|
||||
image.mat.copyTo(img.image);
|
||||
if(profile.cameras[0].darkmap.data)
|
||||
img.image = img.image - profile.cameras[0].darkmap;
|
||||
applyDarkMap(img.image, profile.cameras[0].darkmap);
|
||||
remapedImages.push_back(img);
|
||||
break;
|
||||
}
|
||||
|
|
@ -42,7 +71,7 @@ cv::Mat ImagePipeline::process(const Profile profile, std::vector<Camera::Image>
|
|||
{
|
||||
for(Camera::Image& image : images)
|
||||
{
|
||||
qDebug()<<__FUNCTION__<<"image cam id"<<image.cameraId;
|
||||
qDebug()<<__func__<<"image cam id"<<image.cameraId;
|
||||
bool matched = false;
|
||||
for(auto& camera : profile.cameras)
|
||||
{
|
||||
|
|
@ -51,13 +80,7 @@ cv::Mat ImagePipeline::process(const Profile profile, std::vector<Camera::Image>
|
|||
if(!camera.remapMap.xMat.data || !camera.remapMap.yMat.data)
|
||||
return cv::Mat();
|
||||
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;
|
||||
}
|
||||
applyDarkMap(image.mat, camera.darkmap);
|
||||
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;
|
||||
|
|
@ -81,7 +104,11 @@ cv::Mat ImagePipeline::process(const Profile profile, std::vector<Camera::Image>
|
|||
if(remapedImages.size() > 0)
|
||||
{
|
||||
std::sort(remapedImages.begin(), remapedImages.end(), [](const RemapedImage& imgA, const RemapedImage& imgB) -> bool {return imgA.origin.x < imgB.origin.x;});
|
||||
cv::Mat output = stich(remapedImages);
|
||||
cv::Mat output;
|
||||
if(simpleStichingAlg)
|
||||
output = simpleStich(remapedImages);
|
||||
else
|
||||
output = stich(remapedImages, true);
|
||||
|
||||
if(output.depth() != CV_8U)
|
||||
output.convertTo(output, CV_8U);
|
||||
|
|
@ -125,7 +152,7 @@ void ImagePipeline::apply(std::vector<Camera::Image> images)
|
|||
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, simpleStichingAlg_);
|
||||
futureImageWatchers_.back()->setFuture(futureImage);
|
||||
}
|
||||
}
|
||||
|
|
@ -141,7 +168,7 @@ void ImagePipeline::setProfile(const Profile& profile)
|
|||
{
|
||||
qDebug()<<setup.id;
|
||||
//TODO: dehardcode this
|
||||
setup.remapMap.outputCellSize=150;
|
||||
setup.remapMap.outputCellSize=200;
|
||||
}
|
||||
invalid_ = false;
|
||||
if(!profile_.camerasSufficant(cameras_->getCameras()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue