Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved the stereo gui into the main build system. It does not build by…

… default, but can be turned on in config.options. At the moment, it is mostly disconnected GUI panels, though you can load and view images in the nifty OpenGL viewer widgets.
  • Loading branch information...
commit 0a8a6bda60373654211b187542d1ff58e06294d2 1 parent 12ede22
@broxtronix broxtronix authored
Showing with 1,756 additions and 108 deletions.
  1. +3 −1 configure.ac
  2. +26 −7 src/Makefile.am
  3. +154 −0 src/gui/CostFunctionWidget.cc
  4. +45 −0 src/gui/CostFunctionWidget.h
  5. +2 −2 {stereo_gui → src/gui}/InputWidget.cc
  6. 0  {stereo_gui → src/gui}/InputWidget.h
  7. +72 −0 src/gui/InputWidget.moc.cc
  8. +360 −0 src/gui/KyleStereo.h
  9. +20 −4 {stereo_gui → src/gui}/MainWindow.cc
  10. +3 −2 {stereo_gui → src/gui}/MainWindow.h
  11. +75 −0 src/gui/MainWindow.moc.cc
  12. 0  {stereo_gui → src/gui}/Noise.h
  13. +4 −34 {stereo_gui → src/gui}/PreprocessWidget.cc
  14. 0  {stereo_gui → src/gui}/PreprocessWidget.h
  15. +116 −0 src/gui/PreprocessWidget.moc.cc
  16. +2 −2 {stereo_gui → src/gui}/PreviewGLWidget.cc
  17. 0  {stereo_gui → src/gui}/PreviewGLWidget.frag
  18. +7 −0 {stereo_gui → src/gui}/PreviewGLWidget.h
  19. +60 −0 src/gui/PreviewGLWidget.moc.cc
  20. +36 −0 src/gui/QCompatFormlayout.h
  21. +169 −0 src/gui/SearchWindowWidget.cc
  22. +94 −0 src/gui/SearchWindowWidget.h
  23. +320 −0 src/gui/StereoGuiSession.h
  24. +0 −1  src/stereo.cc
  25. +188 −0 src/stereo_gui.cc
  26. +0 −18 stereo_gui/NOTES
  27. +0 −17 stereo_gui/StereoPipeline.pro
  28. +0 −20 stereo_gui/main.cc
View
4 configure.ac
@@ -217,7 +217,7 @@ AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
# Qt with AutoTroll.
-#AT_WITH_QT
+AT_WITH_QT
if test "yes" = "$ENABLE_VERBOSE"; then
AC_MSG_NOTICE([using PKG_PATHS=$PKG_PATHS])
@@ -283,6 +283,7 @@ AM_CONDITIONAL(HAVE_PKG_ISIS, [test "$HAVE_PKG_ISIS" = "yes"])
##################################################
AX_APP(STEREO, [src], yes, [BOOST BOOST_PROGRAM_OPTIONS BOOST_FILESYSTEM VW VW_CAMERA VW_CARTOGRAPHY VW_STEREO VW_INTEREST_POINT LAPACK MBA SPICE], [ISIS ISIS3RDPARTY QT_CORE QT_GUI])
+AX_APP(STEREOGUI, [src], no, [BOOST BOOST_PROGRAM_OPTIONS BOOST_FILESYSTEM VW VW_CAMERA VW_CARTOGRAPHY VW_STEREO VW_INTEREST_POINT LAPACK MBA SPICE], [ISIS ISIS3RDPARTY])
AX_APP(ORTHOPROJECT, [src], yes, [BOOST BOOST_PROGRAM_OPTIONS BOOST_FILESYSTEM VW VW_CAMERA VW_CARTOGRAPHY VW_STEREO VW_INTEREST_POINT LAPACK MBA SPICE], [ISIS ISIS3RDPARTY QT_CORE QT_GUI])
AX_APP(BUNDLEADJUST, [src], no, [BOOST BOOST_PROGRAM_OPTIONS BOOST_FILESYSTEM VW VW_CAMERA VW_CARTOGRAPHY VW_STEREO VW_INTEREST_POINT LAPACK MBA SPICE], [ISIS ISIS3RDPARTY QT_CORE QT_GUI])
AX_APP(ORBITVIZ, [src], no, [BOOST BOOST_PROGRAM_OPTIONS BOOST_FILESYSTEM VW VW_CAMERA VW_CARTOGRAPHY VW_STEREO VW_INTEREST_POINT LAPACK MBA SPICE], [ISIS ISIS3RDPARTY QT_CORE QT_GUI])
@@ -300,6 +301,7 @@ AX_APP(ISISADJUST, [src], no, [BOOST BOOST_PROGRAM_OPTIONS BOOST_FILESYSTEM VW V
# These are here (instead of inside the APP macro where they belong)
# for backwards compatability with older versions of automake.
AM_CONDITIONAL(MAKE_APP_STEREO, [test "$MAKE_APP_STEREO" = "yes"])
+AM_CONDITIONAL(MAKE_APP_STEREOGUI, [test "$MAKE_APP_STEREOGUI" = "yes"])
AM_CONDITIONAL(MAKE_APP_ORTHOPROJECT, [test "$MAKE_APP_ORTHOPROJECT" = "yes"])
AM_CONDITIONAL(MAKE_APP_BUNDLEADJUST, [test "$MAKE_APP_BUNDLEADJUST" = "yes"])
AM_CONDITIONAL(MAKE_APP_ORBITVIZ, [test "$MAKE_APP_ORBITVIZ" = "yes"])
View
33 src/Makefile.am
@@ -22,7 +22,7 @@
########################################################################
# sources
########################################################################
-#include $(top_srcdir)/config/autotroll.mak
+include $(top_srcdir)/makes/autotroll.mak
if HAVE_PKG_ISIS
isis_sources = Isis/StereoSessionIsis.cc Isis/IsisCameraModel.cc \
@@ -58,6 +58,31 @@ if MAKE_APP_STEREO
stereo_LDFLAGS = $(APP_STEREO_LIBS) $(ASP_LDFLAGS)
endif
+if MAKE_APP_STEREOGUI
+ bin_PROGRAMS += stereo_gui
+ stereo_gui_SOURCES = stereo_gui.cc $(moc_sources) $(ctx_sources) \
+ $(hrsc_sources) $(apollo_sources) \
+ $(generic_stereo_sources) $(isis_sources) \
+ $(rmax_sources) SpiceUtilities.cc gui/MainWindow.cc \
+ gui/MainWindow.moc.cc gui/MainWindow.h \
+ gui/InputWidget.cc gui/InputWidget.moc.cc \
+ gui/InputWidget.h gui/PreprocessWidget.cc \
+ gui/PreprocessWidget.moc.cc gui/PreprocessWidget.h \
+ gui/PreviewGLWidget.cc gui/PreviewGLWidget.moc.cc \
+ gui/PreviewGLWidget.h gui/CostFunctionWidget.cc \
+ gui/CostFunctionWidget.moc.cc \
+ gui/CostFunctionWidget.h gui/SearchWindowWidget.cc \
+ gui/SearchWindowWidget.moc.cc \
+ gui/SearchWindowWidget.h \
+ gui/StereoGuiSession.moc.cc gui/StereoGuiSession.h
+ stereo_gui_CXXFLAGS = $(QT_CXXFLAGS)
+ stereo_gui_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS)
+ stereo_gui_LDFLAGS = $(QT_LDFLAGS) $(APP_STEREOGUI_LIBS) $(ASP_LDFLAGS)
+ stereo_gui_LDADD = $(QT_LIBS)
+
+BUILT_SOURCES = gui/MainWindow.moc.cc
+endif
+
if MAKE_APP_BUNDLEADJUST
bin_PROGRAMS += bundle_adjust
bundle_adjust_SOURCES = $(moc_sources) $(ctx_sources) \
@@ -76,12 +101,6 @@ if MAKE_APP_ORBITVIZ
orbitviz_LDFLAGS = $(APP_ORBITVIZ_LIBS) $(ASP_LDFLAGS)
endif
-# bin_PROGRAMS += aspgui
-# aspgui_SOURCES = aspgui.cc gui/GlWidget.cc
-# aspgui_CXXFLAGS = $(QT_CXXFLAGS) $(QT_INCPATH)
-# aspgui_LDFLAGS = $(QT_LDFLAGS) $(QT_LIBS) $(APP_ASPGUI_LIBS)
-#endif
-
if MAKE_APP_DISPARITYDEBUG
bin_PROGRAMS += disparitydebug
disparitydebug_SOURCES = disparitydebug.cc
View
154 src/gui/CostFunctionWidget.cc
@@ -0,0 +1,154 @@
+#include <QtGui>
+#include <cmath>
+
+#include "gui/CostFunctionWidget.h"
+#include "gui/QCompatFormLayout.h"
+#include "gui/PreviewGLWidget.h"
+
+CostFunctionWidget::CostFunctionWidget(QWidget *parent) : QWidget(parent) {
+ this->blockSignals(true);
+
+ m_imagePreview = new PreviewGLWidget(this);
+ m_leftImagePreview = new PreviewGLWidget(this);
+
+ QTabWidget *previewTab = new QTabWidget;
+ previewTab->addTab(m_imagePreview, "Cost Landscape");
+ previewTab->addTab(m_leftImagePreview, "Left Image");
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(previewTab);
+ mainLayout->addWidget(genSettingsBox("Cost Function Preview Settings"));
+
+ this->setLayout(mainLayout);
+
+ connect(m_xDisparitySlider, SIGNAL(valueChanged(int)), m_xDisparitySpin, SLOT(setValue(int)));
+ connect(m_yDisparitySlider, SIGNAL(valueChanged(int)), m_yDisparitySpin, SLOT(setValue(int)));
+ connect(m_xDisparitySpin, SIGNAL(valueChanged(int)), m_xDisparitySlider, SLOT(setValue(int)));
+ connect(m_yDisparitySpin, SIGNAL(valueChanged(int)), m_yDisparitySlider, SLOT(setValue(int)));
+
+// connect(m_xDisparitySpin, SIGNAL(valueChanged(int)), m_cs, SLOT(setXDisparityPreview(int)));
+// connect(m_yDisparitySpin, SIGNAL(valueChanged(int)), m_cs, SLOT(setYDisparityPreview(int)));
+
+// connect(m_cs, SIGNAL(xDisparityPreviewChanged(int)), m_xDisparitySpin, SLOT(setValue(int)));
+// connect(m_cs, SIGNAL(yDisparityPreviewChanged(int)), m_yDisparitySpin, SLOT(setValue(int)));
+
+// connect(m_cs, SIGNAL(disparityPreviewChanged(int, int)), this, SLOT(recalculateCost()));
+
+// connect(m_cs, SIGNAL(costFunctionObjectChanged(boost::shared_ptr<vw::stereo::CostFunction<vw::float32> >)), this, SLOT(recalculateCost()));
+
+ connect(m_imagePreview, SIGNAL(imageClicked(int, int)), this, SLOT(imageClicked(int, int)));
+ connect(m_leftImagePreview, SIGNAL(imageClicked(int, int)), this, SLOT(imageClicked(int, int)));
+
+ connect(previewTab, SIGNAL(currentChanged(int)), m_imagePreview, SLOT(fitToWindow()));
+ connect(previewTab, SIGNAL(currentChanged(int)), m_leftImagePreview, SLOT(fitToWindow()));
+}
+
+QGroupBox *CostFunctionWidget::genSettingsBox(QString const& name) {
+ QCompatFormLayout *layout = new QCompatFormLayout;
+
+ QLabel *xDisparityLabel = new QLabel("X Disparity:");
+ layout->addRow(xDisparityLabel, genXDisparityKnobs());
+
+ QLabel *yDisparityLabel = new QLabel("Y Disparity:");
+ layout->addRow(yDisparityLabel, genYDisparityKnobs());
+
+ QGroupBox *box = new QGroupBox(name);
+ box->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+ box->setLayout(layout);
+ return box;
+}
+
+QHBoxLayout *CostFunctionWidget::genXDisparityKnobs() {
+ m_xDisparitySpin = new QSpinBox;
+ m_xDisparitySpin->setValue(0);
+ m_xDisparitySpin->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
+
+ m_xDisparitySlider = new QSlider(Qt::Horizontal);
+ m_xDisparitySlider->setValue(0);
+ m_xDisparitySlider->setPageStep(1);
+
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget(m_xDisparitySlider);
+ layout->addWidget(m_xDisparitySpin);
+ return layout;
+}
+
+QHBoxLayout *CostFunctionWidget::genYDisparityKnobs() {
+ m_yDisparitySpin = new QSpinBox;
+ m_yDisparitySpin->setValue(0);
+ m_yDisparitySpin->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
+
+ m_yDisparitySlider = new QSlider(Qt::Horizontal);
+ m_yDisparitySlider->setValue(0);
+ m_yDisparitySlider->setPageStep(1);
+
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget(m_yDisparitySlider);
+ layout->addWidget(m_yDisparitySpin);
+ return layout;
+}
+
+void CostFunctionWidget::recalculateCost() {
+// if (m_cs->hasBothImagesLoaded()) {
+// int width = m_cs->leftImage().cols();
+// int height = m_cs->leftImage().rows();
+// int dx = m_xDisparitySpin->value();
+// int dy = m_yDisparitySpin->value();
+
+// vw::BBox2i corr_window((dx < 0) ? (-dx) : 0,
+// (dy < 0) ? (-dy) : 0,
+// width - abs(dx),
+// height - abs(dy));
+
+// vw::ImageView<vw::float32> result(width, height);
+
+// vw::crop(result, corr_window) = m_cs->getCostFunctionObject()->calculate(corr_window, vw::Vector2i(dx, dy));
+
+// m_imagePreview->setImage(result, true);
+
+// updatePreview();
+// }
+}
+
+void CostFunctionWidget::updatePreview() {
+// m_imagePreview->setCrosshairPosition(m_cs->searchWindowPreviewPoint());
+// m_imagePreview->setCrosshairEnabled(m_cs->crosshairEnabled());
+
+// m_imagePreview->updatePreview();
+
+// m_leftImagePreview->setCrosshairPosition(m_cs->searchWindowPreviewPoint());
+// m_leftImagePreview->setCrosshairEnabled(m_cs->crosshairEnabled());
+
+// m_leftImagePreview->updatePreview();
+}
+
+void CostFunctionWidget::imageClicked(int x, int y) {
+// vw::Vector2i loc(x, y);
+
+// if (loc == m_cs->searchWindowPreviewPoint() && m_cs->crosshairEnabled()) {
+// m_cs->setCrosshairEnabled(false);
+// }
+// else {
+// m_cs->setCrosshairEnabled(true);
+// }
+
+// m_cs->setSearchWindowPreviewPoint(vw::Vector2i(x, y));
+
+// updatePreview();
+}
+
+void CostFunctionWidget::updateWidgets() {
+// int width = m_cs->leftImage().cols();
+// int height = m_cs->leftImage().rows();
+
+// m_xDisparitySpin->setRange(-width, width);
+// m_yDisparitySpin->setRange(-height, height);
+// m_xDisparitySlider->setRange(-width, width);
+// m_yDisparitySlider->setRange(-height, height);
+
+// m_leftImagePreview->setImage(m_cs->leftImage());
+
+// recalculateCost();
+
+// m_imagePreview->fitToWindow();
+}
View
45 src/gui/CostFunctionWidget.h
@@ -0,0 +1,45 @@
+#ifndef __COST_FUNCTION_WIDGET_H__
+#define __COST_FUNCTION_WIDGET_H__
+
+#include <QSpinBox>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QString>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QSlider>
+#include <QCheckBox>
+
+#include <vw/Image.h>
+
+// Forward Declaration
+class PreviewGLWidget;
+
+class CostFunctionWidget : public QWidget {
+ Q_OBJECT
+
+ PreviewGLWidget *m_imagePreview;
+ PreviewGLWidget *m_leftImagePreview;
+
+ QSpinBox *m_xDisparitySpin;
+ QSpinBox *m_yDisparitySpin;
+
+ QSlider *m_xDisparitySlider;
+ QSlider *m_yDisparitySlider;
+
+ QGroupBox *genSettingsBox(QString const& name);
+ QHBoxLayout *genXDisparityKnobs();
+ QHBoxLayout *genYDisparityKnobs();
+
+public:
+ CostFunctionWidget(QWidget *parent = 0);
+
+private slots:
+ void imageClicked(int x, int y);
+ void recalculateCost();
+ void updatePreview();
+
+public slots:
+ void updateWidgets();
+};
+#endif
View
4 stereo_gui/InputWidget.cc → src/gui/InputWidget.cc
@@ -8,8 +8,8 @@
using namespace vw;
-#include "InputWidget.h"
-#include "PreviewGLWidget.h"
+#include "gui/InputWidget.h"
+#include "gui/PreviewGLWidget.h"
class QCompatFormLayout : public QVBoxLayout {
View
0  stereo_gui/InputWidget.h → src/gui/InputWidget.h
File renamed without changes
View
72 src/gui/InputWidget.moc.cc
@@ -0,0 +1,72 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'InputWidget.h'
+**
+** Created: Mon Sep 15 23:51:56 2008
+** by: The Qt Meta Object Compiler version 59 (Qt 4.3.4)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "InputWidget.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'InputWidget.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 59
+#error "This file was generated using the moc from 4.3.4. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+static const uint qt_meta_data_InputWidget[] = {
+
+ // content:
+ 1, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 2, 10, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+
+ // slots: signature, parameters, type, tag, flags
+ 13, 12, 12, 12, 0x08,
+ 39, 12, 12, 12, 0x08,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_InputWidget[] = {
+ "InputWidget\0\0fileBrowseButtonClicked()\0"
+ "loadImage()\0"
+};
+
+const QMetaObject InputWidget::staticMetaObject = {
+ { &QWidget::staticMetaObject, qt_meta_stringdata_InputWidget,
+ qt_meta_data_InputWidget, 0 }
+};
+
+const QMetaObject *InputWidget::metaObject() const
+{
+ return &staticMetaObject;
+}
+
+void *InputWidget::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_InputWidget))
+ return static_cast<void*>(const_cast< InputWidget*>(this));
+ return QWidget::qt_metacast(_clname);
+}
+
+int InputWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QWidget::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ switch (_id) {
+ case 0: fileBrowseButtonClicked(); break;
+ case 1: loadImage(); break;
+ }
+ _id -= 2;
+ }
+ return _id;
+}
View
360 src/gui/KyleStereo.h
@@ -0,0 +1,360 @@
+#ifndef __VW_KYLE_STEREO__
+#define __VW_KYLE_STEREO__
+
+#include <vw/Image.h>
+#include <vw/Stereo.h>
+
+namespace vw {
+ namespace stereo {
+ enum PreprocFilterType {
+ NO_PREPROC_FILTER,
+ LOG_PREPROC_FILTER,
+ SLOG_PREPROC_FILTER,
+ GAUSSIAN_PREPROC_FILTER,
+ BOX_PREPROC_FILTER
+ };
+
+ template <class ImageT>
+ ImageViewRef<typename ImageT::pixel_type> calc_preproc_filter(ImageViewBase<ImageT> const& image, PreprocFilterType preproc_filter, double size = 0) {
+ switch (preproc_filter) {
+ case NO_PREPROC_FILTER:
+ return image.impl();
+ break;
+ case LOG_PREPROC_FILTER:
+ return laplacian_filter(gaussian_filter(image.impl(), size));
+ break;
+ case SLOG_PREPROC_FILTER:
+ return threshold(laplacian_filter(gaussian_filter(image.impl(), size)), 0.0);
+ break;
+ case GAUSSIAN_PREPROC_FILTER:
+ return gaussian_filter(image.impl(), size);
+ break;
+ case BOX_PREPROC_FILTER:
+ return box_filter(image.impl(), Vector2i(int(size), int(size)));
+ break;
+ default:
+ VW_ASSERT(0, ArgumentErr() << "Unrecognized Preprocessing Filter");
+ return ImageViewRef<typename ImageT::pixel_type>();
+ }
+ }
+ }
+}
+
+namespace vw {
+ struct AbsDifferenceFunctor : BinaryReturnTemplateType<DifferenceType> {
+ template <class Arg1T, class Arg2T>
+ typename result<AbsDifferenceFunctor(Arg1T, Arg2T)>::type
+ inline operator()(Arg1T const& arg1, Arg2T const& arg2) const {
+ if (arg1 > arg2)
+ return arg1 - arg2;
+ else
+ return arg2 - arg1;
+ }
+ };
+
+ template <class Image1T, class Image2T>
+ inline BinaryPerPixelView<Image1T, Image2T, AbsDifferenceFunctor> abs_difference(ImageViewBase<Image1T> const& image1, ImageViewBase<Image2T> const& image2) {
+ return BinaryPerPixelView<Image1T, Image2T, AbsDifferenceFunctor>(image1.impl(), image2.impl(), AbsDifferenceFunctor());
+ }
+
+ struct SqDifferenceFunctor : BinaryReturnTemplateType<DifferenceType> {
+ template <class Arg1T, class Arg2T>
+ typename result<SqDifferenceFunctor(Arg1T, Arg2T)>::type
+ inline operator()(Arg1T const& arg1, Arg2T const& arg2) const {
+ return (arg1 - arg2) * (arg1 - arg2);
+ }
+ };
+
+ template <class Image1T, class Image2T>
+ inline BinaryPerPixelView<Image1T, Image2T, SqDifferenceFunctor> sq_difference(ImageViewBase<Image1T> const& image1, ImageViewBase<Image2T> const& image2) {
+ return BinaryPerPixelView<Image1T, Image2T, SqDifferenceFunctor>(image1.impl(), image2.impl(), SqDifferenceFunctor());
+ }
+
+ template<class ImageT>
+ ImageView<typename ImageT::pixel_type> box_filter(ImageViewBase<ImageT> const& img, Vector2i const& kernSize) {
+ typedef typename ImageT::pixel_type PixelT;
+
+ ImageView<PixelT> src = img.impl();
+
+ ImageView<PixelT> result(src.cols(), src.rows());
+
+ Vector<PixelT> cSum(src.cols());
+
+ // Seed the column sum buffer
+ for (int x = 0; x < src.cols(); x++) {
+ cSum(x) = 0;
+ for (int ky = 0; ky < kernSize.y(); ky++) {
+ cSum(x) += src(x, ky);
+ }
+ }
+
+ for (int y = 0; y < src.rows() - kernSize.y(); y++) {
+ // Seed the row sum
+ PixelT rsum = 0;
+ for (int i = 0; i < kernSize.x(); i++) {
+ rsum += cSum(i);
+ }
+
+ for (int x = 0; x < src.cols() - kernSize.x(); x++) {
+ result(x + kernSize.x() / 2, y + kernSize.y() / 2) = rsum;
+ // Update the row sum
+ rsum += cSum(x + kernSize.x()) - cSum(x);
+ }
+
+ // Update the column sum
+ for (int i = 0; i < src.cols(); i++) {
+ cSum(i) += src(i, y + kernSize.y()) - src(i, y);
+ }
+ }
+
+ return result / (kernSize.x() * kernSize.y());
+ }
+}
+
+namespace vw {
+ namespace stereo {
+
+ template <class PixelT>
+ class CostFunction {
+ public:
+ virtual ImageView<PixelT> calculate(BBox2i const& left_bbox, Vector2i const& offset) const = 0;
+ virtual int cols() const = 0;
+ virtual int rows() const = 0;
+ virtual int sample_size() const = 0; // What is the side length of the square of surrounding pixels needed to calculate the cost for a single pixel?
+ virtual ~CostFunction() {}
+ };
+
+ template <class PixelT>
+ class AbsDifferenceCost : public CostFunction<PixelT> {
+ private:
+ int m_kern_size;
+ ImageView <PixelT> m_left, m_right;
+ public:
+ template <class ImageT>
+ AbsDifferenceCost(ImageViewBase<ImageT> const& left, ImageViewBase<ImageT> const& right, int kern_size) : CostFunction<PixelT>(),
+ m_kern_size(kern_size),
+ m_left(copy(left.impl())),
+ m_right(copy(right.impl())) {
+ VW_ASSERT(m_left.cols() == m_right.cols(), ArgumentErr() << "Left and right images not the same width");
+ VW_ASSERT(m_left.rows() == m_right.rows(), ArgumentErr() << "Left and right images not the same height");
+ }
+
+ ImageView<PixelT> calculate(BBox2i const& left_bbox, Vector2i const& offset) const {
+ CropView<ImageView<PixelT> > left_window(m_left, left_bbox);
+ CropView<ImageView<PixelT> > right_window(m_right, left_bbox + offset);
+
+ return box_filter(abs_difference(left_window, right_window), Vector2i(m_kern_size, m_kern_size));
+ }
+
+ int cols() const { return m_left.cols(); }
+ int rows() const { return m_left.rows(); }
+ int sample_size() const { return m_kern_size; }
+ };
+
+ template <class PixelT>
+ class SqDifferenceCost : public CostFunction<PixelT> {
+ private:
+ int m_kern_size;
+ ImageView <PixelT> m_left, m_right;
+ public:
+ template <class ImageT>
+ SqDifferenceCost(ImageViewBase<ImageT> const& left, ImageViewBase<ImageT> const& right, int kern_size) : CostFunction<PixelT>(),
+ m_kern_size(kern_size),
+ m_left(copy(left.impl())),
+ m_right(copy(right.impl())) {
+ VW_ASSERT(m_left.cols() == m_right.cols(), ArgumentErr() << "Left and right images not the same width");
+ VW_ASSERT(m_left.rows() == m_right.rows(), ArgumentErr() << "Left and right images not the same height");
+ }
+
+ ImageView<PixelT> calculate(BBox2i const& left_bbox, Vector2i const& offset) const {
+ CropView<ImageView<PixelT> > left_window(m_left, left_bbox);
+ CropView<ImageView<PixelT> > right_window(m_right, left_bbox + offset);
+
+ return box_filter(sq_difference(left_window, right_window), Vector2i(m_kern_size, m_kern_size));
+ }
+
+ int cols() const { return m_left.cols(); }
+ int rows() const { return m_left.rows(); }
+ int sample_size() const { return m_kern_size; }
+ };
+
+ template <class PixelT>
+ class NormXCorrCost : public CostFunction<PixelT> {
+ private:
+ int m_kern_size;
+
+ ImageView<PixelT> m_left;
+ ImageView<PixelT> m_left_mean;
+ ImageView<PixelT> m_left_variance;
+
+ ImageView<PixelT> m_right;
+ ImageView<PixelT> m_right_mean;
+ ImageView<PixelT> m_right_variance;
+
+ public:
+ template <class ImageT>
+ NormXCorrCost(ImageViewBase<ImageT> const& left, ImageViewBase<ImageT> const& right, int kern_size) : CostFunction<PixelT>(),
+ m_kern_size(kern_size),
+ m_left(copy(left.impl())),
+ m_right(copy(right.impl())) {
+ VW_ASSERT(m_left.cols() == m_right.cols(), ArgumentErr() << "Left and right images not the same width");
+ VW_ASSERT(m_left.rows() == m_right.rows(), ArgumentErr() << "Left and right images not the same height");
+
+ vw::ImageView<PixelT> left_mean_sq = box_filter(m_left * m_left, Vector2i(m_kern_size, m_kern_size));
+ vw::ImageView<PixelT> right_mean_sq = box_filter(m_right * m_right, Vector2i(m_kern_size, m_kern_size));
+
+ m_left_mean = box_filter(m_left, Vector2i(m_kern_size, m_kern_size));
+ m_left_variance = left_mean_sq - m_left_mean * m_left_mean;
+
+ m_right_mean = box_filter(m_right, Vector2i(m_kern_size, m_kern_size));
+ m_right_variance = right_mean_sq - m_right_mean * m_right_mean;
+ }
+
+ ImageView<PixelT> calculate(BBox2i const& left_bbox, Vector2i const& offset) const {
+ CropView<ImageView<PixelT> > left_window(m_left, left_bbox);
+ CropView<ImageView<PixelT> > left_mean_window(m_left_mean, left_bbox);
+ CropView<ImageView<PixelT> > left_variance_window(m_left_variance, left_bbox);
+
+ CropView<ImageView<PixelT> > right_window(m_right, left_bbox + offset);
+ CropView<ImageView<PixelT> > right_mean_window(m_right_mean, left_bbox + offset);
+ CropView<ImageView<PixelT> > right_variance_window(m_right_variance, left_bbox + offset);
+
+ ImageView<PixelT> left_right_mean = box_filter(left_window * right_window, Vector2i(m_kern_size, m_kern_size));
+
+ return -(pow(left_right_mean - left_mean_window * right_mean_window, 2) / left_variance_window / right_variance_window);
+ }
+
+ int cols() const { return m_left.cols(); }
+ int rows() const { return m_left.rows(); }
+ int sample_size() const { return m_kern_size; }
+ };
+
+ template <class PixelT>
+ class BlurCost : public CostFunction<PixelT> {
+ private:
+ boost::shared_ptr<CostFunction<PixelT> > m_base_cost;
+ int m_blur_size;
+ public:
+ BlurCost(boost::shared_ptr<CostFunction<PixelT> > base_cost, int blur_size) : CostFunction<PixelT>(), m_base_cost(base_cost), m_blur_size(blur_size) {}
+
+ ImageView<PixelT> calculate(BBox2i const& left_bbox, Vector2i const& offset) const {
+ return box_filter(m_base_cost->calculate(left_bbox, offset), Vector2i(m_blur_size, m_blur_size));
+ }
+
+ int cols() const { return m_base_cost->cols(); }
+ int rows() const { return m_base_cost->rows(); }
+ int sample_size() const {
+ return m_blur_size + m_base_cost->sample_size();
+ }
+ };
+
+ template <class ScoreT>
+ struct DisparityScore {
+ ScoreT best, worst;
+ int32 hdisp, vdisp;
+
+ DisparityScore() {
+ best = ScalarTypeLimits<ScoreT>::highest();
+ worst = ScalarTypeLimits<ScoreT>::lowest();
+ hdisp = vdisp = 0;
+ }
+ };
+
+ template <class PixelT>
+ ImageView<PixelDisparity<int32> > kylecorrelate(boost::shared_ptr<CostFunction<PixelT> > cost_function,
+ BBox2i const& search_window,
+ ProgressCallback const& progress = ProgressCallback::dummy_instance()
+ ) {
+
+ int width = cost_function->cols();
+ int height = cost_function->rows();
+
+ ImageView<DisparityScore<PixelT> > result_buf(width, height);
+ ImageView<PixelT> cost_buf(width, height);
+
+ // Init the result_buf
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ result_buf(x, y) = DisparityScore<PixelT>();
+ }
+ }
+
+ int currIteration = 0;
+ int totalIterations = (search_window.width() + 1) * (search_window.height() + 1);
+
+ for (int dx = search_window.min().x(); dx <= search_window.max().x(); dx++) {
+ for (int dy = search_window.min().y(); dy <= search_window.max().y(); dy++) {
+ BBox2i corr_window((dx < 0) ? (-dx) : 0,
+ (dy < 0) ? (-dy) : 0,
+ width - abs(dx),
+ height - abs(dy));
+
+ CropView<ImageView<DisparityScore<PixelT> > > result_buf_window(result_buf, corr_window);
+ CropView<ImageView<PixelT> > cost_buf_window(cost_buf, corr_window);
+
+ // Calculate cost function
+ cost_buf_window = cost_function->calculate(corr_window, Vector2i(dx, dy));
+
+ for (int x = 0; x < corr_window.width(); x++) {
+ for (int y = 0; y < corr_window.height(); y++) {
+ if (cost_buf_window(x, y) < result_buf_window(x, y).best) {
+ result_buf_window(x, y).best = cost_buf_window(x, y);
+ result_buf_window(x, y).hdisp = dx;
+ result_buf_window(x, y).vdisp = dy;
+ }
+ if (cost_buf_window(x, y) > result_buf_window(x, y).worst) {
+ result_buf_window(x, y).worst = cost_buf_window(x, y);
+ }
+ }
+ }
+
+ progress.report_fractional_progress(++currIteration, totalIterations);
+ progress.abort_if_requested();
+ }
+ }
+
+ // convert from the local result buffer to the return format
+ ImageView<PixelDisparity<int32> > result(width, height);
+
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ if (result_buf(x, y).best == ScalarTypeLimits<PixelT>::highest()) {
+ result(x, y) = PixelDisparity<int32>();
+ }
+ else {
+ result(x, y) = PixelDisparity<int32>(result_buf(x, y).hdisp, result_buf(x, y).vdisp);
+ }
+ }
+ }
+
+ progress.report_finished();
+
+ return result;
+ }
+
+ template <class PixelT>
+ ImageView<PixelT> correlate_pixel(boost::shared_ptr<CostFunction<PixelT> > cost_function, BBox2i const& search_window, Vector2i const& pixel) {
+
+ ImageView<PixelT> result(search_window.width() + 1, search_window.height() + 1);
+
+ BBox2i corr_window(pixel.x() - cost_function->sample_size() / 2,
+ pixel.y() - cost_function->sample_size() / 2,
+ cost_function->sample_size() + 1,
+ cost_function->sample_size() + 1);
+
+
+ for (int dx = search_window.min().x(); dx <= search_window.max().x(); dx++) {
+ for (int dy = search_window.min().y(); dy <= search_window.max().y(); dy++) {
+ int resultX = dx - search_window.min().x();
+ int resultY = dy - search_window.min().y();
+ result(resultX, resultY) = cost_function->calculate(corr_window, Vector2i(dx, dy))(cost_function->sample_size() / 2, cost_function->sample_size() / 2);
+ }
+ }
+
+ return result;
+ }
+
+ }
+}
+
+#endif
View
24 stereo_gui/MainWindow.cc → src/gui/MainWindow.cc
@@ -1,9 +1,10 @@
#include <QtGui>
-#include "MainWindow.h"
-#include "InputWidget.h"
-#include "PreprocessWidget.h"
-#include "PreviewGLWidget.h"
+#include "gui/MainWindow.h"
+#include "gui/InputWidget.h"
+#include "gui/PreprocessWidget.h"
+#include "gui/CostFunctionWidget.h"
+#include "gui/SearchWindowWidget.h"
#include <vw/FileIO.h>
#include <vw/Image.h>
@@ -19,6 +20,7 @@ MainWindow::MainWindow(int /* argc */, char** /* argv */) {
QTabWidget* tab_widget = new QTabWidget(this);
tab_widget->addTab(genInputTab(), "Input");
tab_widget->addTab(genPreprocessTab(), "Preprocess");
+ tab_widget->addTab(genCostFunctionTab(), "Cost Function");
setCentralWidget(tab_widget);
connect(tab_widget, SIGNAL(currentChanged(int)), this, SLOT(tab_switch(int)));
@@ -127,3 +129,17 @@ QWidget *MainWindow::genPreprocessTab() {
return widget;
}
+QWidget *MainWindow::genCostFunctionTab() {
+ CostFunctionWidget *costPreview = new CostFunctionWidget(this);
+ SearchWindowWidget *searchPreview = new SearchWindowWidget(NULL, this);
+
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget(costPreview);
+ layout->addWidget(searchPreview);
+
+ QWidget *widget = new QWidget;
+ widget->setLayout(layout);
+
+ return widget;
+}
+
View
5 stereo_gui/MainWindow.h → src/gui/MainWindow.h
@@ -24,8 +24,9 @@ private slots:
void create_menus();
void create_status_bar();
- QWidget *MainWindow::genInputTab();
- QWidget *MainWindow::genPreprocessTab();
+ QWidget *genInputTab();
+ QWidget *genPreprocessTab();
+ QWidget *genCostFunctionTab();
QMenu *file_menu;
QMenu *edit_menu;
View
75 src/gui/MainWindow.moc.cc
@@ -0,0 +1,75 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'MainWindow.h'
+**
+** Created: Tue Sep 16 00:52:12 2008
+** by: The Qt Meta Object Compiler version 59 (Qt 4.3.4)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "MainWindow.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'MainWindow.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 59
+#error "This file was generated using the moc from 4.3.4. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+static const uint qt_meta_data_MainWindow[] = {
+
+ // content:
+ 1, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 3, 10, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+
+ // slots: signature, parameters, type, tag, flags
+ 12, 11, 11, 11, 0x08,
+ 22, 20, 11, 11, 0x08,
+ 59, 53, 11, 11, 0x08,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_MainWindow[] = {
+ "MainWindow\0\0about()\0s\0"
+ "update_status_bar(std::string)\0index\0"
+ "tab_switch(int)\0"
+};
+
+const QMetaObject MainWindow::staticMetaObject = {
+ { &QMainWindow::staticMetaObject, qt_meta_stringdata_MainWindow,
+ qt_meta_data_MainWindow, 0 }
+};
+
+const QMetaObject *MainWindow::metaObject() const
+{
+ return &staticMetaObject;
+}
+
+void *MainWindow::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_MainWindow))
+ return static_cast<void*>(const_cast< MainWindow*>(this));
+ return QMainWindow::qt_metacast(_clname);
+}
+
+int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QMainWindow::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ switch (_id) {
+ case 0: about(); break;
+ case 1: update_status_bar((*reinterpret_cast< const std::string(*)>(_a[1]))); break;
+ case 2: tab_switch((*reinterpret_cast< int(*)>(_a[1]))); break;
+ }
+ _id -= 3;
+ }
+ return _id;
+}
View
0  stereo_gui/Noise.h → src/gui/Noise.h
File renamed without changes
View
38 stereo_gui/PreprocessWidget.cc → src/gui/PreprocessWidget.cc
@@ -8,42 +8,12 @@
using namespace vw;
-#include "PreprocessWidget.h"
-#include "PreviewGLWidget.h"
-#include "Noise.h"
+#include "gui/QCompatFormLayout.h"
+#include "gui/PreprocessWidget.h"
+#include "gui/PreviewGLWidget.h"
+#include "gui/Noise.h"
-class QCompatFormLayout : public QVBoxLayout {
-
-public:
- QCompatFormLayout(QWidget *parent = 0) : QVBoxLayout(parent) {}
-
- void addRow(QWidget *label, QWidget *field) {
- QHBoxLayout *layout = new QHBoxLayout;
-
- layout->addWidget(label);
- layout->addWidget(field);
-
- this->addLayout(layout);
- }
-
- void addRow(QWidget *label, QLayout *field) {
- QHBoxLayout *layout = new QHBoxLayout;
-
- layout->addWidget(label);
- layout->addLayout(field);
-
- this->addLayout(layout);
- }
-
- void addRow(QLayout *layout) {
- this->addLayout(layout);
- }
-
- void addRow(QWidget *widget) {
- this->addWidget(widget);
- }
-};
template<class ImageT>
ImageView<typename ImageT::pixel_type> box_filter(ImageViewBase<ImageT> const& img, Vector2i const& kernSize) {
View
0  stereo_gui/PreprocessWidget.h → src/gui/PreprocessWidget.h
File renamed without changes
View
116 src/gui/PreprocessWidget.moc.cc
@@ -0,0 +1,116 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'PreprocessWidget.h'
+**
+** Created: Mon Sep 15 23:51:56 2008
+** by: The Qt Meta Object Compiler version 59 (Qt 4.3.4)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "PreprocessWidget.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'PreprocessWidget.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 59
+#error "This file was generated using the moc from 4.3.4. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+static const uint qt_meta_data_PreprocessComboBox[] = {
+
+ // content:
+ 1, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 0, 0, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_PreprocessComboBox[] = {
+ "PreprocessComboBox\0"
+};
+
+const QMetaObject PreprocessComboBox::staticMetaObject = {
+ { &QComboBox::staticMetaObject, qt_meta_stringdata_PreprocessComboBox,
+ qt_meta_data_PreprocessComboBox, 0 }
+};
+
+const QMetaObject *PreprocessComboBox::metaObject() const
+{
+ return &staticMetaObject;
+}
+
+void *PreprocessComboBox::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_PreprocessComboBox))
+ return static_cast<void*>(const_cast< PreprocessComboBox*>(this));
+ return QComboBox::qt_metacast(_clname);
+}
+
+int PreprocessComboBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QComboBox::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ return _id;
+}
+static const uint qt_meta_data_PreprocessWidget[] = {
+
+ // content:
+ 1, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 3, 10, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+
+ // slots: signature, parameters, type, tag, flags
+ 18, 17, 17, 17, 0x08,
+ 44, 17, 17, 17, 0x08,
+ 58, 17, 17, 17, 0x08,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_PreprocessWidget[] = {
+ "PreprocessWidget\0\0fileBrowseButtonClicked()\0"
+ "updateImage()\0loadImage()\0"
+};
+
+const QMetaObject PreprocessWidget::staticMetaObject = {
+ { &QWidget::staticMetaObject, qt_meta_stringdata_PreprocessWidget,
+ qt_meta_data_PreprocessWidget, 0 }
+};
+
+const QMetaObject *PreprocessWidget::metaObject() const
+{
+ return &staticMetaObject;
+}
+
+void *PreprocessWidget::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_PreprocessWidget))
+ return static_cast<void*>(const_cast< PreprocessWidget*>(this));
+ return QWidget::qt_metacast(_clname);
+}
+
+int PreprocessWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QWidget::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ switch (_id) {
+ case 0: fileBrowseButtonClicked(); break;
+ case 1: updateImage(); break;
+ case 2: loadImage(); break;
+ }
+ _id -= 3;
+ }
+ return _id;
+}
View
4 stereo_gui/PreviewGLWidget.cc → src/gui/PreviewGLWidget.cc
@@ -5,7 +5,7 @@
#include <vw/FileIO.h>
using namespace vw;
-#include "PreviewGLWidget.h"
+#include "gui/PreviewGLWidget.h"
// --------------------------------------------------------------
@@ -270,7 +270,7 @@ void PreviewGLWidget::initializeGL() {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_image.cols(), m_image.rows(), 0,
GL_RGB, GL_FLOAT, &(m_image(0,0)) );
- std::ifstream input_file("PreviewGLWidget.frag");
+ std::ifstream input_file("/Users/mbroxton/projects/StereoPipeline/trunk/src/gui/PreviewGLWidget.frag");
if (!input_file.is_open())
vw_throw(IOErr() << "Could not open GLSL shader file.");
std::string fragment_prog, line;
View
0  stereo_gui/PreviewGLWidget.frag → src/gui/PreviewGLWidget.frag
File renamed without changes
View
7 stereo_gui/PreviewGLWidget.h → src/gui/PreviewGLWidget.h
@@ -2,7 +2,9 @@
#define __PREVIEW_GL_WIDGET_H__
#include <QGLWidget>
+#include <QGLFormat>
#include <QPoint>
+#include <vw/Core/Log.h>
#include <vw/Image/ImageView.h>
#include <vw/Image/Manipulation.h>
#include <vw/Image/Statistics.h>
@@ -24,6 +26,11 @@ class PreviewGLWidget : public QGLWidget {
template <class ViewT>
PreviewGLWidget(QWidget *parent, vw::ImageViewBase<ViewT> const& view) : QGLWidget(parent) {
+ if (!QGLFormat::hasOpenGL()) {
+ vw::vw_out(0) << "This system has no OpenGL support.\nExiting\n\n";
+ exit(1);
+ }
+
setupPreviewGLWidget();
setImage(view);
}
View
60 src/gui/PreviewGLWidget.moc.cc
@@ -0,0 +1,60 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'PreviewGLWidget.h'
+**
+** Created: Tue Sep 16 00:20:04 2008
+** by: The Qt Meta Object Compiler version 59 (Qt 4.3.4)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "PreviewGLWidget.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'PreviewGLWidget.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 59
+#error "This file was generated using the moc from 4.3.4. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+static const uint qt_meta_data_PreviewGLWidget[] = {
+
+ // content:
+ 1, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 0, 0, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_PreviewGLWidget[] = {
+ "PreviewGLWidget\0"
+};
+
+const QMetaObject PreviewGLWidget::staticMetaObject = {
+ { &QGLWidget::staticMetaObject, qt_meta_stringdata_PreviewGLWidget,
+ qt_meta_data_PreviewGLWidget, 0 }
+};
+
+const QMetaObject *PreviewGLWidget::metaObject() const
+{
+ return &staticMetaObject;
+}
+
+void *PreviewGLWidget::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_PreviewGLWidget))
+ return static_cast<void*>(const_cast< PreviewGLWidget*>(this));
+ return QGLWidget::qt_metacast(_clname);
+}
+
+int PreviewGLWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QGLWidget::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ return _id;
+}
View
36 src/gui/QCompatFormlayout.h
@@ -0,0 +1,36 @@
+#ifndef __QCOMPAT_FORM_LAYOUT_H__
+#define __QCOMPAT_FORM_LAYOUT_H__
+
+class QCompatFormLayout : public QVBoxLayout {
+
+public:
+ QCompatFormLayout(QWidget *parent = 0) : QVBoxLayout(parent) {}
+
+ void addRow(QWidget *label, QWidget *field) {
+ QHBoxLayout *layout = new QHBoxLayout;
+
+ layout->addWidget(label);
+ layout->addWidget(field);
+
+ this->addLayout(layout);
+ }
+
+ void addRow(QWidget *label, QLayout *field) {
+ QHBoxLayout *layout = new QHBoxLayout;
+
+ layout->addWidget(label);
+ layout->addLayout(field);
+
+ this->addLayout(layout);
+ }
+
+ void addRow(QLayout *layout) {
+ this->addLayout(layout);
+ }
+
+ void addRow(QWidget *widget) {
+ this->addWidget(widget);
+ }
+};
+
+#endif
View
169 src/gui/SearchWindowWidget.cc
@@ -0,0 +1,169 @@
+#include <QtGui>
+
+#include "gui/SearchWindowWidget.h"
+#include "gui/QCompatFormLayout.h"
+
+SearchWindowWidget::SearchWindowWidget(StereoGuiSession *cs, QWidget *parent) : QWidget(parent) {
+ this->blockSignals(true);
+
+ m_cs = cs;
+
+ m_imagePreview = new PreviewGLWidget(this);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(m_imagePreview);
+ mainLayout->addWidget(genSettingsBox("Search Window Preview Settings"));
+
+ this->setLayout(mainLayout);
+
+ connect(m_kernSizeSpin, SIGNAL(valueChanged(int)), m_cs, SLOT(setKernSize(int)));
+ connect(m_xSearchSizeSpin, SIGNAL(valueChanged(int)), m_cs, SLOT(setXSearchSize(int)));
+ connect(m_ySearchSizeSpin, SIGNAL(valueChanged(int)), m_cs, SLOT(setYSearchSize(int)));
+ connect(m_xSearchOffsetSpin, SIGNAL(valueChanged(int)), m_cs, SLOT(setXSearchOffset(int)));
+ connect(m_ySearchOffsetSpin, SIGNAL(valueChanged(int)), m_cs, SLOT(setYSearchOffset(int)));
+ connect(m_costTypeBox, SIGNAL(valueChanged(StereoGuiSession::CostType)), m_cs, SLOT(setCostType(StereoGuiSession::CostType)));
+ connect(m_costBlurSizeSpin, SIGNAL(valueChanged(int)), m_cs, SLOT(setCostBlurSize(int)));
+
+ connect(m_cs, SIGNAL(kernSizeChanged(int)), m_kernSizeSpin, SLOT(setValue(int)));
+ connect(m_cs, SIGNAL(xSearchSizeChanged(int)), m_xSearchSizeSpin, SLOT(setValue(int)));
+ connect(m_cs, SIGNAL(ySearchSizeChanged(int)), m_ySearchSizeSpin, SLOT(setValue(int)));
+ connect(m_cs, SIGNAL(xSearchOffsetChanged(int)), m_xSearchOffsetSpin, SLOT(setValue(int)));
+ connect(m_cs, SIGNAL(ySearchOffsetChanged(int)), m_ySearchOffsetSpin, SLOT(setValue(int)));
+ connect(m_cs, SIGNAL(costTypeChanged(StereoGuiSession::CostType)), m_costTypeBox, SLOT(setValue(StereoGuiSession::CostType)));
+ connect(m_cs, SIGNAL(costBlurSizeChanged(int)), m_costBlurSizeSpin, SLOT(setValue(int)));
+
+ connect(m_cs, SIGNAL(costFunctionObjectChanged(boost::shared_ptr<vw::stereo::CostFunction<vw::float32> >)), this, SLOT(correlatePixel()));
+ connect(m_cs, SIGNAL(searchWindowPreviewPointChanged(vw::Vector2i)), this, SLOT(correlatePixel()));
+ connect(m_cs, SIGNAL(searchWindowChanged(vw::BBox2i)), this, SLOT(correlatePixel()));
+
+// connect(m_imagePreview, SIGNAL(imageClicked(int, int)), this, SLOT(imageClicked(int, int)));
+}
+
+QGroupBox *SearchWindowWidget::genSettingsBox(QString const& name) {
+ QGroupBox *box = new QGroupBox(name);
+ box->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addLayout(genSettingsKnobs());
+
+ box->setLayout(layout);
+
+ return box;
+}
+
+QHBoxLayout *SearchWindowWidget::genSettingsKnobs() {
+ QLabel *kernSizeLabel = new QLabel("Kernel Size:");
+ m_kernSizeSpin = new QSpinBox;
+
+ QLabel *xSearchSizeLabel = new QLabel("X Search Size:");
+ m_xSearchSizeSpin = new QSpinBox;
+ m_xSearchSizeSpin->setRange(0, 1000);
+
+ QLabel *ySearchSizeLabel = new QLabel("Y Search Size:");
+ m_ySearchSizeSpin = new QSpinBox;
+ m_ySearchSizeSpin->setRange(0, 1000);
+
+ QLabel *xSearchOffsetLabel = new QLabel("X Search Offset:");
+ m_xSearchOffsetSpin = new QSpinBox;
+
+ QLabel *ySearchOffsetLabel = new QLabel("Y Search Offset:");
+ m_ySearchOffsetSpin = new QSpinBox;
+
+ QLabel *costTypeLabel = new QLabel("Cost Type:");
+ m_costTypeBox = new CostTypeComboBox;
+
+ QLabel *costBlurSizeLabel = new QLabel("Cost Blur: ");
+ m_costBlurSizeSpin = new QSpinBox;
+
+ QLabel *currPixelLabel = new QLabel("Current Pixel:");
+ m_currPixelLabel = new QLabel("INVALID");
+
+ QCompatFormLayout *leftLayout = new QCompatFormLayout;
+ leftLayout->addRow(costTypeLabel, m_costTypeBox);
+ leftLayout->addRow(xSearchSizeLabel, m_xSearchSizeSpin);
+ leftLayout->addRow(xSearchOffsetLabel, m_xSearchOffsetSpin);
+ leftLayout->addRow(costBlurSizeLabel, m_costBlurSizeSpin);
+
+ QCompatFormLayout *rightLayout = new QCompatFormLayout;
+ rightLayout->addRow(kernSizeLabel, m_kernSizeSpin);
+ rightLayout->addRow(ySearchSizeLabel, m_ySearchSizeSpin);
+ rightLayout->addRow(ySearchOffsetLabel, m_ySearchOffsetSpin);
+ rightLayout->addRow(currPixelLabel, m_currPixelLabel);
+
+
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addLayout(leftLayout);
+ layout->addLayout(rightLayout);
+
+ return layout;
+}
+
+void SearchWindowWidget::correlatePixel() {
+ if (m_cs->hasBothImagesLoaded()) {
+ int sample_size = m_cs->getCostFunctionObject()->sample_size();
+ vw::BBox2i pixelsAccessed(m_cs->searchWindowPreviewPoint().x() + m_cs->xSearchOffset() - sample_size / 2,
+ m_cs->searchWindowPreviewPoint().y() + m_cs->ySearchOffset() - sample_size / 2,
+ m_cs->xSearchSize() + sample_size,
+ m_cs->ySearchSize() + sample_size);
+
+ vw::BBox2i imageBounds(0, 0, m_cs->leftImage().cols(), m_cs->rightImage().rows());
+
+ if (imageBounds.contains(pixelsAccessed)) {
+ vw::ImageView<vw::float32> result;
+
+ result = vw::stereo::correlate_pixel(m_cs->getCostFunctionObject(), m_cs->searchWindow(), m_cs->searchWindowPreviewPoint());
+
+// m_imagePreview->setImage(result, true, m_cs->xSearchOffset(), m_cs->ySearchOffset());
+// m_imagePreview->fitToWindow();
+
+ int minX = 0, minY = 0;
+ for (int x = 0; x < result.cols(); x++) {
+ for (int y = 0; y < result.rows(); y++) {
+ if (result(x, y) < result(minX, minY)) {
+ minX = x;
+ minY = y;
+ }
+ }
+ }
+
+// m_imagePreview->setCrosshairPosition(minX, minY);
+// m_imagePreview->setCrosshairEnabled(true);
+
+ updatePreview();
+
+ m_currPixelLabel->setText(QString("( %1, %2 )").arg(m_cs->searchWindowPreviewPoint().x()).arg(m_cs->searchWindowPreviewPoint().y()));
+ }
+ else {
+ m_currPixelLabel->setText("INVALID");
+ }
+ }
+}
+
+void SearchWindowWidget::updatePreview() {
+ // This function isn't really necessary at this point,
+ // But I've but it here since all the other forms I've created have it
+// m_imagePreview->updatePreview();
+}
+
+void SearchWindowWidget::updateWidgets() {
+ m_xSearchOffsetSpin->setRange(-m_cs->leftImage().cols(), m_cs->leftImage().cols());
+ m_ySearchOffsetSpin->setRange(-m_cs->leftImage().rows(), m_cs->leftImage().rows());
+
+ m_kernSizeSpin->setValue(m_cs->kernSize());
+
+ m_xSearchSizeSpin->setValue(m_cs->xSearchSize());
+ m_ySearchSizeSpin->setValue(m_cs->ySearchSize());
+
+ m_xSearchOffsetSpin->setValue(m_cs->xSearchOffset());
+ m_ySearchOffsetSpin->setValue(m_cs->ySearchOffset());
+
+ m_costTypeBox->setValue(m_cs->costType());
+
+ m_costBlurSizeSpin->setValue(m_cs->costBlurSize());
+
+ correlatePixel();
+}
+
+void SearchWindowWidget::imageClicked(int x, int y) {
+ m_cs->setDisparityPreview(x + m_cs->xSearchOffset(), y + m_cs->ySearchOffset());
+}
View
94 src/gui/SearchWindowWidget.h
@@ -0,0 +1,94 @@
+#ifndef __SEARCH_WINDOW_WIDGET_H__
+#define __SEARCH_WINDOW_WIDGET_H__
+
+#include <QSpinBox>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QString>
+#include <QLabel>
+#include <QGroupBox>
+#include <QComboBox>
+#include <QMetaObject>
+#include <QMetaEnum>
+
+#include <vw/Image.h>
+
+#include "gui/StereoGuiSession.h"
+#include "gui/PreviewGLWidget.h"
+
+class CostTypeComboBox : public QComboBox {
+ Q_OBJECT
+
+ Q_ENUMS(StereoGuiSession::CostType)
+
+public:
+ CostTypeComboBox(QWidget *parent = 0) : QComboBox(parent) {
+ addItem("Absolute Difference", QVariant("ABS_DIFFERENCE_COST"));
+ addItem("Squared Difference", QVariant("SQ_DIFFERENCE_COST"));
+ addItem("Normalized Cross Correlation", QVariant("NORM_XCORR_COST"));
+
+ connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(emitValueChanged()));
+ }
+
+ StereoGuiSession::CostType value() const {
+ QString costTypeName = itemData(currentIndex()).toString();
+
+ const QMetaObject metaobject = StereoGuiSession::staticMetaObject;
+ int enumidx = metaobject.indexOfEnumerator("CostType");
+
+ return static_cast<StereoGuiSession::CostType>(metaobject.enumerator(enumidx).keyToValue(costTypeName.toAscii().constData()));
+ }
+
+ public slots:
+ void setValue(StereoGuiSession::CostType value) {
+ const QMetaObject metaobject = StereoGuiSession::staticMetaObject;
+ int enumidx = metaobject.indexOfEnumerator("CostType");
+
+ QString costTypeName(metaobject.enumerator(enumidx).valueToKey(value));
+
+ setCurrentIndex(findData(costTypeName));
+ }
+
+ private slots:
+ void emitValueChanged() {
+ emit valueChanged(value());
+ }
+
+ signals:
+ void valueChanged(StereoGuiSession::CostType);
+};
+
+class SearchWindowWidget : public QWidget {
+ Q_OBJECT
+
+ private:
+ StereoGuiSession *m_cs;
+ PreviewGLWidget *m_imagePreview;
+
+ QSpinBox *m_kernSizeSpin;
+ QSpinBox *m_costBlurSizeSpin;
+ QSpinBox *m_xSearchSizeSpin;
+ QSpinBox *m_ySearchSizeSpin;
+ QSpinBox *m_xSearchOffsetSpin;
+ QSpinBox *m_ySearchOffsetSpin;
+
+ CostTypeComboBox *m_costTypeBox;
+
+ QGroupBox *genSettingsBox(QString const& name);
+ QHBoxLayout *genSettingsKnobs();
+
+ QLabel *m_currPixelLabel;
+
+ public:
+ SearchWindowWidget(StereoGuiSession *cs, QWidget *parent = 0);
+
+ public slots:
+ void updateWidgets();
+
+ private slots:
+ void updatePreview();
+ void correlatePixel();
+ void imageClicked(int x, int y);
+};
+
+#endif
View
320 src/gui/StereoGuiSession.h
@@ -0,0 +1,320 @@
+#ifndef __STEREO_GUI_SESSION_H__
+#define __STEREO_GUI_SESSION_H__
+
+#include <QObject>
+
+#include <vw/Image.h>
+#include <vw/Stereo.h>
+
+#include "gui/KyleStereo.h"
+
+class StereoGuiSession : public QObject {
+ Q_OBJECT
+
+ Q_ENUMS(CostType)
+ Q_ENUMS(SubpixelType)
+
+public:
+ enum CostType {
+ ABS_DIFFERENCE_COST,
+ SQ_DIFFERENCE_COST,
+ NORM_XCORR_COST
+ };
+
+ enum SubpixelType {
+ PARABOLA_SUBPIXEL,
+ AFFINE_ADAPTIVE_SUBPIXEL
+ };
+
+private:
+ int m_kernSize;
+ int m_costBlurSize;
+ int m_xSearchOffset, m_ySearchOffset;
+ int m_xSearchSize, m_ySearchSize;
+
+ vw::ImageView<vw::float32> m_leftImage, m_rightImage;
+ vw::ImageView<vw::PixelDisparity<vw::float32> > m_disparity_map;
+
+ CostType m_costType;
+ SubpixelType m_subpixelType;
+
+ boost::shared_ptr<vw::stereo::CostFunction<vw::float32> > m_costFunctionObject;
+
+ vw::Vector2i m_searchWindowPreviewPoint;
+ bool m_crosshairEnabled;
+
+ int m_xDisparityPreview, m_yDisparityPreview;
+
+ void updateCostFunctionObject() {
+ if (hasBothImagesLoaded()) {
+ switch (m_costType) {
+ case ABS_DIFFERENCE_COST:
+ m_costFunctionObject = boost::shared_ptr<vw::stereo::CostFunction<vw::float32> >(new vw::stereo::AbsDifferenceCost<vw::float32>(m_leftImage, m_rightImage, m_kernSize));
+ break;
+ case SQ_DIFFERENCE_COST:
+ m_costFunctionObject = boost::shared_ptr<vw::stereo::CostFunction<vw::float32> >(new vw::stereo::SqDifferenceCost<vw::float32>(m_leftImage, m_rightImage, m_kernSize));
+ break;
+ case NORM_XCORR_COST:
+ m_costFunctionObject = boost::shared_ptr<vw::stereo::CostFunction<vw::float32> >(new vw::stereo::NormXCorrCost<vw::float32>(m_leftImage, m_rightImage, m_kernSize));
+ break;
+ }
+
+ if (m_costBlurSize != 0) {
+ m_costFunctionObject = boost::shared_ptr<vw::stereo::CostFunction<vw::float32> >(new vw::stereo::BlurCost<vw::float32>(m_costFunctionObject, m_costBlurSize));
+ }
+
+ emit costFunctionObjectChanged(m_costFunctionObject);
+ }
+ }
+
+ public:
+ StereoGuiSession(QObject *parent = 0) : QObject(parent),
+ m_kernSize(25),
+ m_costBlurSize(0),
+
+ m_xSearchOffset(0),
+ m_ySearchOffset(0),
+
+ m_xSearchSize(10),
+ m_ySearchSize(10),
+
+ m_costType(ABS_DIFFERENCE_COST),
+
+ m_crosshairEnabled(false),
+
+ m_xDisparityPreview(0),
+ m_yDisparityPreview(0) {}
+
+public:
+
+ // Convenience functions
+
+ vw::BBox2i searchWindow() {
+ return vw::BBox2i(m_xSearchOffset, m_ySearchOffset, m_xSearchSize, m_ySearchSize);
+ }
+
+ bool hasBothImagesLoaded() {
+ return m_leftImage.cols() != 0 &&
+ m_rightImage.cols() != 0 &&
+ m_leftImage.cols() == m_rightImage.cols() &&
+ m_rightImage.rows() == m_rightImage.rows();
+ }
+
+ bool hasDisparityMapLoaded() {
+ return m_disparity_map.cols() != 0 &&
+ m_disparity_map.cols() != 0 &&
+ m_disparity_map.cols() == m_rightImage.cols() &&
+ m_disparity_map.rows() == m_rightImage.rows();
+ }
+
+ boost::shared_ptr<vw::stereo::CostFunction<vw::float32> > getCostFunctionObject() {
+ return m_costFunctionObject;
+ }
+
+ void setDisparityPreview(int dx, int dy) {
+ m_xDisparityPreview = dx;
+ m_yDisparityPreview = dy;
+ emit xDisparityPreviewChanged(dx);
+ emit yDisparityPreviewChanged(dy);
+ emit disparityPreviewChanged(dx, dy);
+ }
+
+ // Properties
+
+ int kernSize() {
+ return m_kernSize;
+ }
+
+ int costBlurSize() {
+ return m_costBlurSize;
+ }
+
+ int xSearchSize() {
+ return m_xSearchSize;
+ }
+
+ int ySearchSize() {
+ return m_ySearchSize;
+ }
+
+ int xSearchOffset() {
+ return m_xSearchOffset;
+ }
+
+ int ySearchOffset() {
+ return m_ySearchOffset;
+ }
+
+ vw::ImageView<vw::float32> leftImage() {
+ return m_leftImage;
+ }
+
+ vw::ImageView<vw::float32> rightImage() {
+ return m_rightImage;
+ }
+
+ vw::ImageView<vw::PixelDisparity<vw::float32> > disparityMap() {
+ return m_disparity_map;
+ }
+
+ CostType costType() {
+ return m_costType;
+ }
+
+ vw::Vector2i searchWindowPreviewPoint() {
+ return m_searchWindowPreviewPoint;
+ }
+
+ bool crosshairEnabled() {
+ return m_crosshairEnabled;
+ }
+
+ int xDisparityPreview() {
+ return m_xDisparityPreview;
+ }
+
+ int yDisparityPreview() {
+ return m_yDisparityPreview;
+ }
+
+public slots:
+ void setKernSize(int kernSize) {
+ if (m_kernSize != kernSize) {
+ m_kernSize = kernSize;
+ updateCostFunctionObject();
+ emit kernSizeChanged(kernSize);
+ }
+ }
+
+ void setCostBlurSize(int costBlurSize) {
+ if (m_costBlurSize != costBlurSize) {
+ m_costBlurSize = costBlurSize;
+ updateCostFunctionObject();
+ emit costBlurSizeChanged(costBlurSize);
+ }
+ }
+
+ void setXSearchSize(int xSearchSize) {
+ if (m_xSearchSize != xSearchSize) {
+ m_xSearchSize = xSearchSize;
+ emit xSearchSizeChanged(xSearchSize);
+ emit searchWindowChanged(searchWindow());
+ }
+ }
+
+ void setYSearchSize(int ySearchSize) {
+ if (m_ySearchSize != ySearchSize) {
+ m_ySearchSize = ySearchSize;
+ emit ySearchSizeChanged(ySearchSize);
+ emit searchWindowChanged(searchWindow());
+ }
+ }
+
+ void setXSearchOffset(int xSearchOffset) {
+ if (m_xSearchOffset != xSearchOffset) {
+ m_xSearchOffset = xSearchOffset;
+ emit xSearchOffsetChanged(xSearchOffset);
+ emit searchWindowChanged(searchWindow());
+ }
+ }
+
+ void setYSearchOffset(int ySearchOffset) {
+ if (m_ySearchOffset != ySearchOffset) {
+ m_ySearchOffset = ySearchOffset;
+ emit ySearchOffsetChanged(ySearchOffset);
+ emit searchWindowChanged(searchWindow());
+ }
+ }
+
+ void setLeftImage(vw::ImageView<vw::float32> leftImage) {
+ m_leftImage = leftImage;
+ updateCostFunctionObject();
+ emit leftImageChanged(leftImage);
+ }
+
+ void setRightImage(vw::ImageView<vw::float32> rightImage) {
+ m_rightImage = rightImage;
+ updateCostFunctionObject();
+ emit rightImageChanged(rightImage);
+ }
+
+ void setImages(vw::ImageView<vw::float32> leftImage, vw::ImageView<vw::float32> rightImage) {
+ m_leftImage = leftImage;
+ m_rightImage = rightImage;
+ updateCostFunctionObject();
+ emit leftImageChanged(leftImage);
+ emit rightImageChanged(rightImage);
+ }
+
+ void setDisparityMap(vw::ImageView<vw::PixelDisparity<vw::float32> > disparityMap) {
+ m_disparity_map = disparityMap;
+ emit disparityMapChanged(disparityMap);
+ }
+
+ void setCostType(StereoGuiSession::CostType costType) {
+ if (m_costType != costType) {
+ m_costType = costType;
+ updateCostFunctionObject();
+ emit costTypeChanged(costType);
+ }
+ }
+
+ void setSubpixelType(StereoGuiSession::SubpixelType subpixelType) {
+ if (m_subpixelType != subpixelType) {
+ m_subpixelType = subpixelType;
+ emit subpixelTypeChanged(subpixelType);
+ }
+ }
+
+ void setSearchWindowPreviewPoint(vw::Vector2i searchWindowPreviewPoint) {
+ if (m_searchWindowPreviewPoint != searchWindowPreviewPoint) {
+ m_searchWindowPreviewPoint = searchWindowPreviewPoint;
+ emit searchWindowPreviewPointChanged(searchWindowPreviewPoint);
+ }
+ }
+
+ void setCrosshairEnabled(bool crosshairEnabled) {
+ if (m_crosshairEnabled != crosshairEnabled) {
+ m_crosshairEnabled = crosshairEnabled;
+ emit crosshairEnabledChanged(crosshairEnabled);
+ }
+ }
+
+ void setXDisparityPreview(int xDisparityPreview) {
+ if (m_xDisparityPreview != xDisparityPreview) {
+ m_xDisparityPreview = xDisparityPreview;
+ emit xDisparityPreviewChanged(xDisparityPreview);
+ emit disparityPreviewChanged(m_xDisparityPreview, m_yDisparityPreview);
+ }
+ }
+
+ void setYDisparityPreview(int yDisparityPreview) {
+ if (m_yDisparityPreview != yDisparityPreview) {
+ m_yDisparityPreview = yDisparityPreview;
+ emit yDisparityPreviewChanged(yDisparityPreview);
+ emit disparityPreviewChanged(m_xDisparityPreview, m_yDisparityPreview);
+ }
+ }
+
+signals:
+ void kernSizeChanged(int kernSize);
+ void costBlurSizeChanged(int costBlurSize);
+ void xSearchSizeChanged(int xSearchSize);
+ void ySearchSizeChanged(int ySearchSize);
+ void xSearchOffsetChanged(int xSearchOffset);
+ void ySearchOffsetChanged(int ySearchOffset);
+ void leftImageChanged(vw::ImageView<vw::float32> leftImage);
+ void rightImageChanged(vw::ImageView<vw::float32> rightImage);
+ void disparityMapChanged(vw::ImageView<vw::PixelDisparity<vw::float32> > disparityMap);
+ void costTypeChanged(StereoGuiSession::CostType costType);
+ void subpixelTypeChanged(StereoGuiSession::SubpixelType subpixelType);
+ void searchWindowPreviewPointChanged(vw::Vector2i searchWindowPreviewPoint);
+ void crosshairEnabledChanged(bool crosshairEnabled);
+ void costFunctionObjectChanged(boost::shared_ptr<vw::stereo::CostFunction<vw::float32> > costFunctionObject);
+ void searchWindowChanged(vw::BBox2i searchWindow);
+ void xDisparityPreviewChanged(int xDisparityPreview);
+ void yDisparityPreviewChanged(int yDisparityPreview);
+ void disparityPreviewChanged(int xDisparityPreview, int yDisparityPreview);
+};
+
+#endif
View
1  src/stereo.cc
@@ -108,7 +108,6 @@ void print_usage(po::options_description const& visible_options) {
//***********************************************************************
// MAIN
//***********************************************************************
-
int main(int argc, char* argv[]) {
// The default file type are automatically registered the first time
View
188 src/stereo_gui.cc
@@ -0,0 +1,188 @@
+// __BEGIN_LICENSE__
+//
+// Copyright (C) 2008 United States Government as represented by the
+// Administrator of the National Aeronautics and Space Administration
+// (NASA). All Rights Reserved.
+//
+// Copyright 2008 Carnegie Mellon University. All rights reserved.
+//
+// This software is distributed under the NASA Open Source Agreement
+// (NOSA), version 1.3. The NOSA has been approved by the Open Source
+// Initiative. See the file COPYING at the top of the distribution
+// directory tree for the complete NOSA document.
+//
+// THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
+// KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
+// LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
+// SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
+// A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
+// THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
+// DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
+//
+// __END_LICENSE__
+
+/// \file stereo_gui.cc
+///
+
+// Qt
+#include <QApplication>
+#include <QWidget>
+
+// Boost
+#include <boost/program_options.hpp>
+using namespace boost;
+namespace po = boost::program_options;
+
+// Standard Library
+#include <iostream>
+
+// VW
+#include <vw/Core.h>
+#include <vw/Image.h>
+#include <vw/Math.h>
+#include <vw/FileIO.h>
+#include <vw/Stereo.h>
+using namespace vw;
+using namespace vw::math;
+using namespace vw::camera;
+using namespace vw::stereo;
+
+#include "gui/MainWindow.h"
+#include "StereoSettings.h"
+#include "stereo.h"
+#include "StereoSession.h"
+#include "MRO/DiskImageResourceDDD.h" // support for Malin DDD image files
+#include "HRSC/StereoSessionHRSC.h"
+#include "MOC/StereoSessionMOC.h"
+#include "apollo/StereoSessionApolloMetric.h"
+#include "MRO/StereoSessionCTX.h"
+#include "RMAX/StereoSessionRmax.h"
+
+#if defined(ASP_HAVE_PKG_ISIS) && ASP_HAVE_PKG_ISIS == 1
+#include "Isis/DiskImageResourceIsis.h"
+#include "Isis/StereoSessionIsis.h"
+#endif
+
+// Allows FileIO to correctly read/write these pixel types
+namespace vw {
+ template<> struct PixelFormatID<Vector3> { static const PixelFormatEnum value = VW_PIXEL_GENERIC_3_CHANNEL; };
+ template<> struct PixelFormatID<PixelDisparity<float> > { static const PixelFormatEnum value = VW_PIXEL_GENERIC_3_CHANNEL; };
+}
+
+void print_usage(po::options_description const& visible_options) {
+ std::cout << "\nUsage: stereo_gui [options] <Left_input_image> <Right_input_image> [Left_camera_file] [Right_camera_file] <output_file_prefix>\n"
+ << " Extensions are automaticaly added to the output files.\n"
+ << " Camera model arguments may be optional for some stereo session types (e.g. isis).\n"
+ << " Stereo parameters should be set in the stereo.default file.\n\n";
+ std::cout << visible_options << std::endl;
+}
+
+int main(int argc, char *argv[]) {
+
+ // The default file type are automatically registered the first time
+ // a file is opened or created, however we want to override some of
+ // the defaults, so we explicitly register them here before registering
+ // our own FileIO driver code.
+ DiskImageResource::register_default_file_types();
+
+ // Register the DDD file handler with the Vision Workbench
+ // DiskImageResource system. DDD is the proprietary format used by
+ // Malin Space Science Systems.
+ DiskImageResource::register_file_type(".ddd",
+ DiskImageResourceDDD::type_static(),
+ &DiskImageResourceDDD::construct_open,
+ &DiskImageResourceDDD::construct_create);
+
+#if defined(ASP_HAVE_PKG_ISIS) && ASP_HAVE_PKG_ISIS == 1
+ // Register the Isis file handler with the Vision Workbench
+ // DiskImageResource system.
+ DiskImageResource::register_file_type(".cub",
+ DiskImageResourceIsis::type_static(),
+ &DiskImageResourceIsis::construct_open,
+ &DiskImageResourceIsis::construct_create);
+#endif
+ /*************************************/
+ /* Parsing of command line arguments */
+ /*************************************/
+
+ // Boost has a nice command line parsing utility, which we use here
+ // to specify the type, size, help string, etc, of the command line
+ // arguments.
+ int debug_level;
+ unsigned cache_size;
+ std::string stereo_session_string;
+ std::string stereo_default_filename;
+ std::string in_file1, in_file2, cam_file1, cam_file2, extra_arg1, extra_arg2, extra_arg3, extra_arg4;
+ std::string out_prefix;
+
+ po::options_description visible_options("Options");
+ visible_options.add_options()
+ ("help,h", "Display this help message")
+ ("cache", po::value<unsigned>(&cache_size)->default_value(1800), "Cache size, in megabytes")
+ ("session-type,t", po::value<std::string>(&stereo_session_string), "Select the stereo session type to use for processing. [options: pinhole isis]")
+ ("stereo-file,s", po::value<std::string>(&stereo_default_filename)->default_value("./stereo.default"), "Explicitly specify the stereo.default file to use. [default: ./stereo.default]")
+ ("debug-level,d", po::value<int>(&debug_level)->default_value(vw::DebugMessage-1), "Set the debugging output level. (0-50+)");
+
+ po::options_description positional_options("Positional Options");
+ positional_options.add_options()
+ ("left-input-image", po::value<std::string>(&in_file1), "Left Input Image")
+ ("right-input-image", po::value<std::string>(&in_file2), "Right Input Image")
+ ("left-camera-model", po::value<std::string>(&cam_file1), "Left Camera Model File")
+ ("right-camera-model", po::value<std::string>(&cam_file2), "Right Camera Model File")
+ ("output-prefix", po::value<std::string>(&out_prefix), "Prefix for output filenames")
+ ("extra_argument1", po::value<std::string>(&extra_arg1), "Extra Argument 1")
+ ("extra_argument2", po::value<std::string>(&extra_arg2), "Extra Argument 2")
+ ("extra_argument3", po::value<std::string>(&extra_arg3), "Extra Argument 3")
+ ("extra_argument4", po::value<std::string>(&extra_arg4), "Extra Argument 4");
+ po::positional_options_description positional_options_desc;
+ positional_options_desc.add("left-input-image", 1);
+ positional_options_desc.add("right-input-image", 1);
+ positional_options_desc.add("left-camera-model", 1);
+ positional_options_desc.add("right-camera-model", 1);
+ positional_options_desc.add("output-prefix", 1);
+ positional_options_desc.add("extra_argument1", 1);
+ positional_options_desc.add("extra_argument2", 1);
+ positional_options_desc.add("extra_argument3", 1);
+ positional_options_desc.add("extra_argument4", 1);
+
+ po::options_description all_options;
+ all_options.add(visible_options).add(positional_options);
+
+ po::variables_map vm;
+ po::store( po::command_line_parser( argc, argv ).options(all_options).positional(positional_options_desc).run(), vm );
+ po::notify( vm );
+
+ // If the command line wasn't properly formed or the user requested
+ // help, we print an usage message.
+ if( vm.count("help") ) {
+ print_usage(visible_options);
+ exit(0);
+ }
+
+ // Read the stereo.conf file
+ stereo_settings().read(stereo_default_filename);
+
+ // Set the Vision Workbench debug level
+ set_debug_level(debug_level);
+ Cache::system_cache().resize( cache_size*1024*1024 ); // Set cache to 1Gb
+
+ // Create a fresh stereo session and query it for the camera models.
+ StereoSession::register_session_type( "hrsc", &StereoSessionHRSC::construct);
+ StereoSession::register_session_type( "moc", &StereoSessionMOC::construct);
+ StereoSession::register_session_type( "metric", &StereoSessionApolloMetric::construct);
+ StereoSession::register_session_type( "ctx", &StereoSessionCTX::construct);
+ StereoSession::register_session_type( "rmax", &StereoSessionRmax::construct);
+#if defined(ASP_HAVE_PKG_ISIS) && ASP_HAVE_PKG_ISIS == 1
+ StereoSession::register_session_type( "isis", &StereoSessionIsis::construct);
+#endif
+ StereoSession* session = StereoSession::create(stereo_session_string);
+ session->initialize(in_file1, in_file2, cam_file1, cam_file2,
+ out_prefix, extra_arg1, extra_arg2, extra_arg3, extra_arg4);
+
+
+ // Start up the Qt GUI
+ QApplication app(argc, argv);
+ MainWindow main_window(argc, argv);
+ main_window.show();
+ return app.exec();
+}
View
18 stereo_gui/NOTES
@@ -1,18 +0,0 @@
-Transforming the image:
-Left Mouse + drag - pan
-Right Mouse + drag / Mousewheel - zoom
-f : zoom to fit
-1 : zoom to 1:1
-+ : zoom in
-- : zoom out
-
-Editing Exposure (via glsl)
-g + drag : gain (contrast)
-o + drag : offset (exposure)
-v + drag : gamma
-c : toggle colormap
-
-Display:
-- Image coordinates
-- pixel values
-- Current zoom level
View
17 stereo_gui/StereoPipeline.pro
@@ -1,17 +0,0 @@
-######################################################################
-# Automatically generated by qmake (2.01a) Sat Sep 6 23:26:54 2008
-######################################################################
-
-VWDIR = /Users/mbroxton/projects/VisionWorkbench/trunk/build
-BOOSTDIR = /opt/local
-
-TEMPLATE = app
-TARGET =
-DEPENDPATH += .
-INCLUDEPATH += . $$VWDIR/include $$BOOSTDIR/include
-LIBS += -L$$VWDIR/lib -lvw -lvwCore -lvwMath -lvwImage -lvwFileIO -L$$BOOSTDIR/lib
-QT += opengl
-
-# Input
-HEADERS += MainWindow.h PreviewGLWidget.h InputWidget.h PreprocessWidget.h Noise.h
-SOURCES += main.cc MainWindow.cc PreviewGLWidget.cc InputWidget.cc PreprocessWidget.cc
View
20 stereo_gui/main.cc
@@ -1,20 +0,0 @@
-#include <QApplication>
-#include <QWidget>
-#include <QGLFormat>
-#include "MainWindow.h"
-
-// Standard Library
-#include <iostream>
-
-int main(int argc, char *argv[]) {
- QApplication app(argc, argv);
-
- if (!QGLFormat::hasOpenGL()) {
- std::cerr << "This system has no OpenGL support.\nExiting\n\n";
- return 1;
- }
-
- MainWindow main_window(argc, argv);
- main_window.show();
- return app.exec();
-}
Please sign in to comment.
Something went wrong with that request. Please try again.