New preview - still very buggy
This commit is contained in:
parent
f7ba865d6e
commit
90dba3f819
8 changed files with 89 additions and 14 deletions
|
|
@ -44,6 +44,7 @@ struct BatchResult {
|
|||
ProcessingResult result[BATCHSIZE];
|
||||
quint64 frame_no[BATCHSIZE];
|
||||
quint64 hit_hist[10] = {};
|
||||
cv::Mat batch_composit = cv::Mat::zeros(100, 100, CV_8UC1); // TODO config size!
|
||||
};
|
||||
|
||||
struct ResList {
|
||||
|
|
|
|||
|
|
@ -182,7 +182,14 @@ void IdsCam::buffer_polling()
|
|||
for(int i = 0; i < batch_results_n; i++)
|
||||
{
|
||||
BatchResult* cur = results.results.at(i);
|
||||
emit new_hist_av(cur->hit_hist);
|
||||
if(i == batch_results_n-1)
|
||||
{
|
||||
emit new_hist_av(cur->hit_hist);
|
||||
//cv::addWeighted(average_all, 0.5, cur->batch_composit, 0.5, 0, average_all); // WTF is this crashing with errpr "not same type" >>> tomorrow
|
||||
cv::Mat* data_ptr = new cv::Mat(cur->batch_composit.clone());
|
||||
emit new_batch_view(data_ptr); // Cleanup handled by reciever!
|
||||
emit new_avg_view(&average_all);
|
||||
}
|
||||
delete cur;
|
||||
}
|
||||
results.results.clear();
|
||||
|
|
|
|||
5
idscam.h
5
idscam.h
|
|
@ -13,6 +13,7 @@
|
|||
#include <QTimer>
|
||||
#include <QImage>
|
||||
#include <QElapsedTimer>
|
||||
#include <opencv4/opencv2/opencv.hpp>
|
||||
|
||||
#include "processing.h"
|
||||
#include "framebatch.h"
|
||||
|
|
@ -69,10 +70,14 @@ private:
|
|||
ProcessingConfig pro_cfg{};
|
||||
|
||||
ResList results{};
|
||||
|
||||
cv::Mat average_all = cv::Mat::zeros(100, 100, CV_8UC1); // TODO config size!
|
||||
signals:
|
||||
void new_status_text(QString text);
|
||||
void vis_new_frame(QImage img);
|
||||
void new_hist_av(quint64 hit_hist[10]);
|
||||
void new_batch_view(cv::Mat *img);
|
||||
void new_avg_view(cv::Mat *img);
|
||||
};
|
||||
|
||||
#endif // IDSCAM_H
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(&cam, &IdsCam::new_status_text, ui->infotext, &QLabel::setText);
|
||||
connect(&cam, &IdsCam::vis_new_frame, this, &MainWindow::visualize_new_frame);
|
||||
connect(&cam, &IdsCam::new_hist_av, stats.histogramm, &BarChart::new_batch_data);
|
||||
connect(&cam, &IdsCam::new_batch_view, &stats, &StatsView::vis_new_batch_view);
|
||||
connect(&cam, &IdsCam::new_avg_view, &stats, &StatsView::vis_new_avg_view);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ Worker::Worker(FrameBatch *batch, ArvStream *stream, ResList *result)
|
|||
void Worker::run()
|
||||
{
|
||||
batch_result = new BatchResult(); // Constructed as a pointer! Will need cleanup when done!
|
||||
|
||||
for(int i=0; i<BATCHSIZE; i++)
|
||||
{
|
||||
batch_result->result[i] = processArvBuffer(batch->frames[i], cfg);
|
||||
|
|
@ -17,6 +18,17 @@ void Worker::run()
|
|||
|
||||
quint8 hits = std::min(batch_result->result[i].extended_data.length(), 10); // Max 10 hits in histogramm
|
||||
batch_result->hit_hist[hits]++;
|
||||
|
||||
foreach(Hit hit, batch_result->result[i].extended_data)
|
||||
{
|
||||
int cy = std::min((hit.cy*100) / batch_result->result[i].composit.rows, 100); // TODO config size!
|
||||
int cx = std::min((hit.cx*100) / batch_result->result[i].composit.cols, 100); // TODO config size!
|
||||
try {
|
||||
batch_result->batch_composit.at<uint8_t>(cy, cx) += 255/batch_result->result[i].extended_data.length();
|
||||
} catch (cv::Exception) {
|
||||
qDebug() << "FIXME"; // Why is this also crashing - FIXME!!!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Append Batch Result to Output Data - with mutex!
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ StatsView::StatsView(QWidget *parent)
|
|||
|
||||
connect(ui->closeButton, &QPushButton::clicked, this, &QDialog::close);
|
||||
|
||||
counts = new CountChart(ui->counts);
|
||||
ui->live_view->setScaledContents(1);
|
||||
ui->avg_view->setScaledContents(1);
|
||||
histogramm = new BarChart(ui->histogramm);
|
||||
}
|
||||
|
||||
|
|
@ -18,6 +19,20 @@ StatsView::~StatsView()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void StatsView::vis_new_batch_view(cv::Mat *img)
|
||||
{
|
||||
if(cur_batch_vis != nullptr)
|
||||
delete cur_batch_vis;
|
||||
cur_batch_vis = img;
|
||||
|
||||
ui->live_view->setPixmap(QPixmap::fromImage(QImage((uchar*)img->data, img->cols, img->rows, QImage::Format_Grayscale8)));
|
||||
}
|
||||
|
||||
void StatsView::vis_new_avg_view(cv::Mat *img)
|
||||
{
|
||||
ui->avg_view->setPixmap(QPixmap::fromImage(QImage((uchar*)img->data, img->cols, img->rows, QImage::Format_Grayscale8)));
|
||||
}
|
||||
|
||||
CountChart::CountChart(QChartView *view)
|
||||
:chartView(view)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <QBarSeries>
|
||||
#include <QBarSet>
|
||||
#include <QBarCategoryAxis>
|
||||
#include <opencv4/opencv2/opencv.hpp>
|
||||
|
||||
using namespace QtCharts;
|
||||
|
||||
|
|
@ -50,11 +51,14 @@ class StatsView : public QDialog
|
|||
public:
|
||||
explicit StatsView(QWidget *parent = nullptr);
|
||||
~StatsView();
|
||||
CountChart *counts;
|
||||
BarChart *histogramm;
|
||||
public slots:
|
||||
void vis_new_batch_view(cv::Mat *img);
|
||||
void vis_new_avg_view(cv::Mat *img);
|
||||
|
||||
private:
|
||||
Ui::StatsView *ui;
|
||||
cv::Mat* cur_batch_vis = nullptr;
|
||||
};
|
||||
|
||||
#endif // STATSVIEW_H
|
||||
|
|
|
|||
51
statsview.ui
51
statsview.ui
|
|
@ -16,17 +16,7 @@
|
|||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QChartView" name="counts" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QChartView" name="histogramm" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
|
|
@ -36,6 +26,45 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="live_view">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="avg_view">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue