shutter speed value could not be adjusted on this camera.
So I tried modifying the exposure value, but it doesn’t solve the problem.
here is my code
#include <iostream>
#include <ctime>
#include <libobsensor/ObSensor.hpp>
#include <opencv2/opencv.hpp>
#include "libobsensor/hpp/Pipeline.hpp"
#include "libobsensor/hpp/Error.hpp"
#include <thread>
using std::cout;
using std::endl;
int main(int argc, char **argv) try {
// Create a pipeline with default device
ob::Pipeline pipe;
// Configure which streams to enable or disable for the Pipeline by creating a Config
std::shared_ptr<ob::Config> config = std::make_shared<ob::Config>();
std::shared_ptr<ob::VideoStreamProfile> colorProfile = nullptr;
try {
auto colorProfiles = pipe.getStreamProfileList(OB_SENSOR_COLOR);
colorProfile = colorProfiles->getVideoStreamProfile(640, 480, OB_FORMAT_RGB, 30);
config->enableStream(colorProfile->as<ob::VideoStreamProfile>());
}
catch(...) {
std::cout << "color stream not found!" << std::endl;
}
try {
auto depthProfiles = pipe.getStreamProfileList(OB_SENSOR_DEPTH);
auto depthProfile = depthProfiles->getVideoStreamProfile(640, 480, OB_FORMAT_Y12, 30);
config->enableStream(depthProfile->as<ob::VideoStreamProfile>());
}
catch(...) {
std::cout << "depth stream not found!" << std::endl;
}
try {
auto irProfiles = pipe.getStreamProfileList(OB_SENSOR_IR);
auto irProfile = irProfiles->getVideoStreamProfile(640, 480, OB_FORMAT_ANY, 30);
config->enableStream(irProfile->as<ob::VideoStreamProfile>());
}
catch(...) {
std::cout << "ir stream not found!" << std::endl;
}
// Configure the alignment mode as hardware D2C alignment
config->setAlignMode(ALIGN_D2C_HW_MODE);
try {
pipe.start(config);
}
catch (ob::Error& e) {
std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() << std::endl;
}
auto dev = pipe.getDevice();
dev->setIntProperty(OB_PROP_COLOR_BRIGHTNESS_INT, 0);
dev->setIntProperty(OB_PROP_COLOR_CONTRAST_INT, 25);
dev->setIntProperty(OB_PROP_COLOR_SATURATION_INT, 70);
//dev->setIntProperty(OB_PROP_COLOR_HUE_INT, 40);
dev->setIntProperty(OB_PROP_COLOR_GAMMA_INT, 72);
dev->setIntProperty(OB_PROP_COLOR_GAIN_INT, 0);
dev->setIntProperty(OB_PROP_COLOR_SHARPNESS_INT, 6);
dev->setIntProperty(OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT, 2);
dev->setBoolProperty(OB_PROP_COLOR_AUTO_EXPOSURE_BOOL, false);
dev->setIntProperty(OB_PROP_COLOR_EXPOSURE_INT, 20);
clock_t past;
int key;
cv::Mat colorMat, depthMat, dstMat = cv::Mat(640*2, 480, CV_8UC3);
while(true) {
past = clock();
auto frameSet = pipe.waitForFrames(100);
if (frameSet == nullptr) {
continue;
}
auto colorFrame = frameSet->colorFrame();
auto depthFrame = frameSet->depthFrame();
if (colorFrame != nullptr && depthFrame != nullptr) {
colorMat = cv::Mat(colorFrame->height(), colorFrame->width(), CV_8UC3, colorFrame->data());
cv::cvtColor(colorMat, colorMat, cv::COLOR_RGB2BGR);
depthMat = cv::Mat(depthFrame->height(), depthFrame->width(), CV_16UC1, depthFrame->data());
cv::normalize(depthMat, depthMat, 0, 255, cv::NORM_MINMAX, CV_8UC1);
cv::cvtColor(depthMat, depthMat, cv::COLOR_GRAY2BGR);
cv::hconcat(colorMat, depthMat, dstMat);
cv::imshow("dst", dstMat);
}
//cout << clock() - past << endl;
key = cv::waitKey(33);
if (key == 'C' || key == 'c' || key == 'Q' || key == 'q') break;
}
pipe.stop();
return 0;
}
catch(ob::Error &e) {
std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() << std::endl;
exit(EXIT_FAILURE);
}