Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/FindSpinnaker.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (WITH_SPINNAKER)
SPINNAKER_LIBS STREQUAL "SPINNAKER_LIBS-NOTFOUND" OR
SPINNAKER_INCLUDE_DIRS STREQUAL "SPINNAKER_INCLUDE_DIRS-NOTFOUND"
))
add_definitions( -DSPINNAKER )
add_definitions( -DSPINNAKER_AVAILABLE )
message(STATUS "Spinnaker found, activating Spinnaker support.")
else()
set(SPINNAKER_INCLUDE_DIRS "")
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindmvIMPACT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (WITH_MVIMPACT)
mvIMPACT_LIBS STREQUAL "mvIMPACT_LIBS-NOTFOUND" OR
mvIMPACT_INCLUDE_DIRS STREQUAL "mvIMPACT_INCLUDE_DIRS-NOTFOUND"
))
add_definitions( -DMVIMPACT )
add_definitions( -DMVIMPACT_AVAILABLE )
message(STATUS "mvIMPACT found, activating mvIMPACT support.")
else()
set(mvIMPACT_INCLUDE_DIRS "")
Expand Down
4 changes: 2 additions & 2 deletions src/Perspective.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void Perspective::geometryCheck(const int width, const int height, const double
}
}
fieldScale = fieldScaleSum / (float)n * resamplingFactor;
LOG("Field scale: " << minFieldScale << "mm/px < " << fieldScale << "mm/px < " << maxFieldScale << "mm/px");
VP_LOG("Field scale: " << minFieldScale << "mm/px < " << fieldScale << "mm/px < " << maxFieldScale << "mm/px");

//update visibleFieldExtent
Eigen::Vector2f center = model.image2field({0.0f, 0.0f}, (float)maxBotHeight).head<2>();
Expand Down Expand Up @@ -121,7 +121,7 @@ void Perspective::geometryCheck(const int width, const int height, const double
if(reprojectedFieldSize[1] % 2)
reprojectedFieldSize[1]++;

LOG("Visible field extent: " << visibleFieldExtent.transpose() << "mm (xmin,xmax,ymin,ymax) Field scale: " << fieldScale << "mm/px");
VP_LOG("Visible field extent: " << visibleFieldExtent.transpose() << "mm (xmin,xmax,ymin,ymax) Field scale: " << fieldScale << "mm/px");
}

Eigen::Vector2f Perspective::flat2field(const Eigen::Vector2f& pos) const {
Expand Down
11 changes: 9 additions & 2 deletions src/Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ Resources::Resources(const std::string& configPath) : fieldReference(), configPa
configMtime = (int64_t)st.st_mtim.tv_sec * 1000000000 + st.st_mtim.tv_nsec;

openCl = std::make_shared<OpenCL>();
camera = openCamera(CameraConfig(getOptional(config["camera"])));

CameraConfig camConfig(getOptional(config["camera"]));
camera = openCamera(camConfig);
camera->setResolution(camConfig.width, camConfig.height);
camera->setExposure(camConfig.exposure);
camera->setGain(camConfig.gain);
camera->setGamma(camConfig.gamma);
camera->setWhiteBalance(camConfig.whiteBalanceType, camConfig.whiteBalanceBlue, camConfig.whiteBalanceRed);

camId = config["cam_id"].as<int>(0);
if (camId < 0 || camId > 7) {
Expand Down Expand Up @@ -230,7 +237,7 @@ void Resources::reloadConfigIfChanged() {
try {
YAML::Node config = YAML::LoadFile(configPath);
applyTunables(config);
LOG("Reloaded tunables from " << configPath);
VP_LOG("Reloaded tunables from " << configPath);
} catch(const YAML::Exception& e) {
WARN("Config reload failed, keeping previous values: " << e.what());
}
Expand Down
2 changes: 1 addition & 1 deletion src/calib/Distortion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool calibrateDistortion(const std::vector<std::vector<Eigen::Vector2f>>& linePo
lm.minimize(k);

if((k(1) < 0.0f || k(2) < 0.0f || k(1) >= model.size.x() || k(2) >= model.size.y())) {
LOG("Principal point outside of image, aborting calibration for this frame");
VP_LOG("Principal point outside of image, aborting calibration for this frame");
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/calib/GeomModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ void geometryCalibration(const Resources& r, const CLImage& rgba) {

const int halfLineWidth = halfLineWidthEstimation(r, gray);
diag.half_line_width = halfLineWidth;
LOG("Half line width: " << halfLineWidth);
VP_LOG("Half line width: " << halfLineWidth);

cv::Mat thresholded(gray.rows, gray.cols, CV_8UC1, 0.0);
thresholdImage(r, gray, halfLineWidth, thresholded);
Expand All @@ -520,12 +520,12 @@ void geometryCalibration(const Resources& r, const CLImage& rgba) {
lines.emplace_back(a, b);
}
diag.raw_line_segments = (int)lines.size();
LOG("Line segments: " << lines.size());
VP_LOG("Line segments: " << lines.size());

const std::vector<CVLines> compoundLines = groupLineSegments(r, lines);
const CVLines mergedLines = mergeLineSegments(compoundLines);
diag.merged_line_count = (int)mergedLines.size();
LOG("Lines: " << mergedLines.size());
VP_LOG("Lines: " << mergedLines.size());

std::vector<std::vector<Eigen::Vector2f>> mergedPixels(mergedLines.size());
{
Expand Down Expand Up @@ -568,7 +568,7 @@ void geometryCalibration(const Resources& r, const CLImage& rgba) {

model.updateDerived();
int error = modelError(r, model, linePixels);
LOG("Best model: " << model << " error " << (error/(float)linePixels.size()));
VP_LOG("Best model: " << model << " error " << (error/(float)linePixels.size()));

diag.focal_length = model.focalLength;
diag.position = model.pos;
Expand Down
8 changes: 4 additions & 4 deletions src/driver/cameradriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
#include "cameradriver.h"

#include "driver/opencvdriver.h"
#ifdef SPINNAKER
#ifdef SPINNAKER_AVAILABLE
#include "driver/spinnakerdriver.h"
#endif
#ifdef MVIMPACT
#ifdef MVIMPACT_AVAILABLE
#include "driver/mvimpactdriver.h"
#endif

Expand Down Expand Up @@ -76,12 +76,12 @@ bool CameraConfig::autoGamma() const {


std::unique_ptr<CameraDriver> openCamera(const CameraConfig& config) {
#ifdef SPINNAKER
#ifdef SPINNAKER_AVAILABLE
if(config.driverType == "SPINNAKER")
return std::make_unique<SpinnakerDriver>(config);
#endif

#ifdef MVIMPACT
#ifdef MVIMPACT_AVAILABLE
if(config.driverType == "MVIMPACT")
return std::make_unique<MVImpactDriver>(config);
#endif
Expand Down
18 changes: 18 additions & 0 deletions src/driver/cameradriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ class CameraDriver {

// Bound to the driver for reproducibility during testing with files.
virtual double getTime();

virtual uint32_t getWidth() = 0;
virtual uint32_t getHeight() = 0;
virtual void setResolution(uint32_t width, uint32_t height) = 0;

virtual float getExposure() = 0;
virtual void setExposure(float exposure) = 0;

virtual float getGain() = 0;
virtual void setGain(float gain) = 0;

virtual float getGamma() = 0;
virtual void setGamma(float gamma) = 0;

virtual WhiteBalanceType getWhiteBalanceType() = 0;
virtual float getWhiteBalanceBlue() = 0;
virtual float getWhiteBalanceRed() = 0;
virtual void setWhiteBalance(WhiteBalanceType type, float blue, float red) = 0;
};


Expand Down
59 changes: 59 additions & 0 deletions src/driver/dummydriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "dummydriver.h"
#include "driver/cameradriver.h"
#include "opencl.h"

DummyDriver::DummyDriver(const CameraConfig& config): image(std::make_shared<RawImage>(&PixelFormat::BGR8, 640, 480, "dummy")) {}

std::shared_ptr<RawImage> DummyDriver::readImage() {
return image;
}

const PixelFormat DummyDriver::format() {
return PixelFormat::BGR8;
}

double DummyDriver::expectedFrametime() {
return 1.0 / 30.0;
}

uint32_t DummyDriver::getWidth() {
return 640;
}

uint32_t DummyDriver::getHeight() {
return 480;
}

void DummyDriver::setResolution(uint32_t width, uint32_t height) {}

float DummyDriver::getExposure() {
return 0.0f;
}

void DummyDriver::setExposure(float exposure) {}

float DummyDriver::getGain() {
return 0.0f;
}

void DummyDriver::setGain(float gain) {}

float DummyDriver::getGamma() {
return 1.0f;
}

void DummyDriver::setGamma(float gamma) {}

WhiteBalanceType DummyDriver::getWhiteBalanceType() {
return WhiteBalanceType::WhiteBalanceType_AutoOutdoor;
}

float DummyDriver::getWhiteBalanceBlue() {
return 1.0f;
}

float DummyDriver::getWhiteBalanceRed() {
return 1.0f;
}

void DummyDriver::setWhiteBalance(WhiteBalanceType type, float blue, float red) {}
35 changes: 35 additions & 0 deletions src/driver/dummydriver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once
#include "cameradriver.h"

class DummyDriver : public CameraDriver {
public:
explicit DummyDriver(const CameraConfig& config);
~DummyDriver() override = default;

std::shared_ptr<RawImage> readImage() override;

const PixelFormat format() override;

double expectedFrametime() override;

uint32_t getWidth() override;
uint32_t getHeight() override;
void setResolution(uint32_t width, uint32_t height) override;

float getExposure() override;
void setExposure(float exposure) override;

float getGain() override;
void setGain(float gain) override;

float getGamma() override;
void setGamma(float gamma) override;

WhiteBalanceType getWhiteBalanceType() override;
float getWhiteBalanceBlue() override;
float getWhiteBalanceRed() override;
void setWhiteBalance(WhiteBalanceType type, float blue, float red) override;

private:
std::shared_ptr<RawImage> image;
};
Loading
Loading