2 #include <opencv2/imgproc.hpp>
10 cv::Size inputSize = bgrImg.size();
13 int cropW = 0, cropH = 0;
25 int cropW = 0, cropH = 0;
27 scale = (float)
_config->manipWidth / (
float)manipImg.size().width;
28 cv::resize(manipImg, manipImg, cv::Size(), scale, scale);
30 else if (
_config->convertManipToGray)
36 if (
_config->convertManipToGray)
38 cv::cvtColor(manipImg, manipImg, cv::COLOR_BGR2GRAY);
41 SENSFramePtr sensFrame = std::make_unique<SENSFrame>(timePt,
58 float horizFOVDev = fovDegFallbackGuess;
59 if (
_config->streamConfig->focalLengthPix > 0)
113 bool convertManipToGray)
119 bool cameraWasStarted =
false;
123 cameraWasStarted =
true;
134 int trackingImgW = 640;
136 if (manipWidth > 0 && manipHeight > 0 &&
137 ((
float)targetWidth / (
float)targetHeight) >
138 ((
float)manipWidth / (
float)manipHeight))
139 searchWdivH = (float)manipWidth / (
float)manipHeight;
141 searchWdivH = (float)targetWidth / (
float)targetHeight;
144 int aproxHighImgW = targetWidth;
146 std::pair<const SENSCameraDeviceProps*, const SENSCameraStreamConfig*> bestConfig =
150 if (!bestConfig.first && !bestConfig.second)
154 bestConfig = props.
findBestMatchingConfig(facing, 65.f, aproxHighImgW, (
int)((float)aproxHighImgW / searchWdivH));
155 if (!bestConfig.first && !bestConfig.second)
161 _config = std::make_unique<SENSCvCameraConfig>(bestConfig.first,
175 if (cameraWasStarted)
176 _camera->
start(bestConfig.first->deviceId(), *bestConfig.second);
229 cv::Size(
_config->streamConfig->widthPix,
_config->streamConfig->heightPix),
std::chrono::high_resolution_clock::time_point SENSTimePt
SENSCameraFacing
Definition of camera facing.
std::shared_ptr< SENSFrame > SENSFramePtr
std::shared_ptr< SENSFrameBase > SENSFrameBasePtr
High Resolution Timer class using C++11.
Pure abstract camera class.
virtual SENSFrameBasePtr latestFrame()=0
Get the latest captured frame. If no frame was captured the frame will be empty (null).
virtual const SENSCameraConfig & start(std::string deviceId, const SENSCameraStreamConfig &streamConfig, bool provideIntrinsics=true)=0
virtual bool started() const =0
virtual const SENSCaptureProps & captureProperties()=0
Get SENSCaptureProps which contains necessary information about all available camera devices and thei...
virtual void stop()=0
Stop a started camera device.
std::pair< const SENSCameraDeviceProps *const, const SENSCameraStreamConfig *const > findBestMatchingConfig(SENSCameraFacing facing, const float horizFov, const int width, const int height) const
Helper function to find a camera device and stream configuration with certain characteristics.
bool supportsCameraFacing(const SENSCameraFacing &facing) const
cv::Mat scaledCameraMat()
bool supportsFacing(SENSCameraFacing facing)
ConfigReturnCode
error code definition, will be returned by configure in case of failure. See method advice() for expl...
@ ERROR_FACING_NOT_AVAILABLE
@ WARN_TARGET_SIZE_NOT_FOUND
void guessAndSetCalibration(float fovDegFallbackGuess)
std::unique_ptr< SENSCalibration > _calibrationManip
std::unique_ptr< SENSCvCameraConfig > _config
void setCalibration(const SENSCalibration &calibration, bool buildUndistortionMaps)
Set calibration and adapt it to current image size. Camera has to be configured, before this function...
SENSCvCamera(SENSCamera *camera)
ConfigReturnCode configure(SENSCameraFacing facing, int targetWidth, int targetHeight, int manipWidth, int manipHeight, bool mirrorH, bool mirrorV, bool convertManipToGray)
const SENSCalibration *const calibration() const
returns SENSCalibration if it was started (maybe a guessed one from a fovV guess)....
SENSFramePtr latestFrame()
std::unique_ptr< SENSCalibration > _calibration
The calibration is used for computer vision applications. This calibration is adjusted to fit to the ...
SENSFramePtr processNewFrame(const SENSTimePt &timePt, cv::Mat bgrImg, cv::Mat intrinsics, bool intrinsicsChanged)
std::unique_ptr< SENSCalibration > _calibrationOverwrite
Class for holding computer information.
void mirrorImage(cv::Mat &img, bool mirrorH, bool mirrorV)
float calcFOVDegFromFocalLengthPix(const float focalLengthPix, const int imgLength)
void cropImage(cv::Mat &img, float targetWdivH, int &cropW, int &cropH)