-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add stereo image pair loading & rgbd piping with embedded hfov in depth
- Loading branch information
1 parent
7b5f0ec
commit 9547592
Showing
15 changed files
with
626 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright I3D Robotics Ltd, 2020 | ||
* Author: Josh Veitch-Michaelis, Ben Knight ([email protected]) | ||
*/ | ||
|
||
#include "stereocamerafromimage.h" | ||
|
||
bool StereoCameraFromImage::openCamera(){ | ||
if (isConnected()){ | ||
closeCamera(); | ||
} | ||
int fps = stereoCameraSettings_.fps; | ||
std::string fname_l = stereoCameraSerialInfo_.left_camera_serial; | ||
std::string fname_r = stereoCameraSerialInfo_.right_camera_serial; | ||
|
||
left_raw = cv::imread(fname_l,cv::IMREAD_UNCHANGED); | ||
right_raw = cv::imread(fname_r,cv::IMREAD_UNCHANGED); | ||
|
||
//TODO check image files exist | ||
|
||
image_height = left_raw.size().height; | ||
image_width = left_raw.size().width; | ||
image_bitdepth = 1; //TODO get bit depth | ||
emit update_size(image_width, image_height, image_bitdepth); | ||
|
||
setFPS(fps); | ||
|
||
connected = true; | ||
return connected; | ||
} | ||
|
||
bool StereoCameraFromImage::closeCamera(){ | ||
connected = false; | ||
emit disconnected(); | ||
return true; | ||
} | ||
|
||
bool StereoCameraFromImage::captureSingle(){ | ||
|
||
// Simulate frame rate | ||
double delay_needed = (1000.0/(video_fps+1)) - frame_timer.elapsed(); | ||
if(delay_needed > 0){ | ||
QThread::msleep(delay_needed); | ||
} | ||
|
||
frame_timer.restart(); | ||
|
||
//send_error(CAPTURE_ERROR); | ||
//emit captured_fail(); | ||
emit captured_success(); | ||
emit captured(); | ||
return true; | ||
} | ||
|
||
void StereoCameraFromImage::captureThreaded(){ | ||
future = QtConcurrent::run(this, &StereoCameraFromImage::captureSingle); | ||
} | ||
|
||
bool StereoCameraFromImage::enableCapture(bool enable){ | ||
if (enable){ | ||
//Start capture thread | ||
connect(this, SIGNAL(captured()), this, SLOT(captureThreaded())); | ||
capturing = true; | ||
captureThreaded(); | ||
} else { | ||
//Stop capture thread | ||
disconnect(this, SIGNAL(captured()), this, SLOT(captureThreaded())); | ||
capturing = false; | ||
} | ||
return true; | ||
} | ||
|
||
std::vector<AbstractStereoCamera::StereoCameraSerialInfo> StereoCameraFromImage::listSystems(){ | ||
std::vector<AbstractStereoCamera::StereoCameraSerialInfo> connected_serial_infos; | ||
return connected_serial_infos; | ||
} | ||
|
||
bool StereoCameraFromImage::setFPS(int fps){ | ||
if (!isCapturing()){ | ||
frame_rate = fps; | ||
video_fps = fps; | ||
return true; | ||
} else { | ||
qDebug() << "Cannot set FPS while capturing. Stop capturing and try again."; | ||
return false; | ||
} | ||
} | ||
|
||
StereoCameraFromImage::~StereoCameraFromImage(void) { | ||
if (connected){ | ||
closeCamera(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright I3D Robotics Ltd, 2020 | ||
* Author: Josh Veitch-Michaelis, Ben Knight ([email protected]) | ||
*/ | ||
|
||
#ifndef STEREOCAMERAFROMIMAGE_H | ||
#define STEREOCAMERAFROMIMAGE_H | ||
|
||
#include <abstractstereocamera.h> | ||
#include <QThread> | ||
|
||
//! Stereo image feed | ||
/*! | ||
Vitual stereo camera from image feed | ||
*/ | ||
|
||
class StereoCameraFromImage : public AbstractStereoCamera | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
explicit StereoCameraFromImage(AbstractStereoCamera::StereoCameraSerialInfo serial_info, | ||
AbstractStereoCamera::StereoCameraSettings camera_settings, | ||
QObject *parent = 0) : | ||
AbstractStereoCamera(serial_info, camera_settings, parent){ | ||
} | ||
|
||
static std::vector<AbstractStereoCamera::StereoCameraSerialInfo> listSystems(); | ||
|
||
~StereoCameraFromImage(void); | ||
|
||
public slots: | ||
// Implimentations of virtual functions from parent class | ||
bool openCamera(); | ||
bool closeCamera(); | ||
bool captureSingle(); | ||
bool enableCapture(bool enable); | ||
bool setFPS(int fps); | ||
bool setExposure(double){return false;} //NA | ||
bool enableAutoExposure(bool){return false;} //NA | ||
bool setPacketSize(int){return false;} //NA | ||
bool setPacketDelay(int){return false;} //NA | ||
bool enableTrigger(bool){return false;} //NA | ||
bool enableAutoGain(bool){return false;} //NA | ||
bool setGain(int){return false;} //NA | ||
bool setBinning(int){return false;} //NA | ||
|
||
void captureThreaded(); | ||
|
||
signals: | ||
void videoPosition(int); | ||
|
||
private: | ||
QFuture<void> future; | ||
QElapsedTimer frame_timer; | ||
double video_fps; | ||
}; | ||
|
||
#endif // STEREOCAMERAFROMIMAGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "loadstereoimagepairdialog.h" | ||
#include "ui_loadstereoimagepairdialog.h" | ||
|
||
LoadStereoImagePairDialog::LoadStereoImagePairDialog(QWidget *parent) : | ||
QDialog(parent), | ||
ui(new Ui::LoadStereoImagePairDialog) | ||
{ | ||
ui->setupUi(this); | ||
|
||
connect(ui->btnBrowseLeft, SIGNAL(clicked()), this, SLOT(requestLeftImageFilepath())); | ||
connect(ui->btnBrowseRight, SIGNAL(clicked()), this, SLOT(requestRightImageFilepath())); | ||
connect(ui->btnCancel, SIGNAL(clicked()), this, SLOT(reject())); | ||
connect(ui->btnLoad, SIGNAL(clicked()), this, SLOT(accept())); | ||
} | ||
|
||
void LoadStereoImagePairDialog::reject() | ||
{ | ||
leftFilepathValid = rightFilepathValid = false; | ||
QDialog::reject(); | ||
} | ||
|
||
void LoadStereoImagePairDialog::requestLeftImageFilepath(){ | ||
leftFilepathValid = requestImageFilepath(left_image_filepath); | ||
ui->txtLeftImageFilename->setText(QString::fromStdString(left_image_filepath)); | ||
} | ||
|
||
void LoadStereoImagePairDialog::requestRightImageFilepath(){ | ||
rightFilepathValid = requestImageFilepath(right_image_filepath); | ||
ui->txtRightImageFilename->setText(QString::fromStdString(right_image_filepath)); | ||
} | ||
|
||
bool LoadStereoImagePairDialog::requestImageFilepath(std::string &fname){ | ||
QString qfname = QFileDialog::getOpenFileName( | ||
this, tr("Open image"), "", tr("Images (*.png *.jpeg *.jpg)")); | ||
fname = qfname.toStdString(); | ||
QFileInfo check_file(qfname); | ||
return (fname != "" && check_file.exists() && check_file.isFile()); | ||
} | ||
|
||
LoadStereoImagePairDialog::~LoadStereoImagePairDialog() | ||
{ | ||
delete ui; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef LOADSTEREOIMAGEPAIRDIALOG_H | ||
#define LOADSTEREOIMAGEPAIRDIALOG_H | ||
|
||
#include <QDialog> | ||
#include <QFileDialog> | ||
#include <QFileInfo> | ||
|
||
namespace Ui { | ||
class LoadStereoImagePairDialog; | ||
} | ||
|
||
class LoadStereoImagePairDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit LoadStereoImagePairDialog(QWidget *parent = nullptr); | ||
~LoadStereoImagePairDialog(); | ||
|
||
bool isFilepathsValid(){return leftFilepathValid && rightFilepathValid;} | ||
|
||
std::string getLeftImageFilepath(){return left_image_filepath;} | ||
std::string getRightImageFilepath(){return right_image_filepath;} | ||
|
||
private slots: | ||
void requestLeftImageFilepath(); | ||
void requestRightImageFilepath(); | ||
void reject(); | ||
|
||
private: | ||
Ui::LoadStereoImagePairDialog *ui; | ||
|
||
std::string left_image_filepath = ""; | ||
std::string right_image_filepath = ""; | ||
bool leftFilepathValid = false; | ||
bool rightFilepathValid = false; | ||
|
||
bool requestImageFilepath(std::string &fname); | ||
}; | ||
|
||
#endif // LOADSTEREOIMAGEPAIRDIALOG_H |
Oops, something went wrong.