const double _zoom_in_step { 0.02 };
const double _zoom_out_step { 0.1 };
const unsigned int _max_loss_cnt { 60 };
- bool _is_working { false };
bool _detected { false };
cv::Point2f _center {};
bool isWorking() override
{
- return _is_working;
+ // Invoke the postprocessing if face is detected or zoom scale value is same as min zoom scale(default value).
+ // if zoom scale is different from min zoom scale then it means that we are under the postprocessing.
+ if (_detected || _zoom_scale != _min_zoom_scale)
+ return true;
+
+ return false;
}
};
copied->is_owned = false;
if (_user_cb) {
- // if postprocessor isn't in progress, postprocess current camera preview image.
- if (!_postprocessor->isWorking()) {
+ // if postprocessor is in progress, postprocess current camera preview image.
+ if (_postprocessor->isWorking()) {
ImageDataType zoom_data = dynamic_cast<ImageDataType &>(_postprocessor->getOutput(*copied));
_user_cb(zoom_data.ptr, zoom_data.width, zoom_data.height, zoom_data.byte_per_pixel, _user_data);
ImageDataType &image_data = dynamic_cast<ImageDataType &>(data);
cv::Mat cv_image(cv::Size(image_data.width, image_data.height), CV_MAKETYPE(CV_8U, 3), image_data.ptr);
- cv::cvtColor(cv_image, cv_image, cv::COLOR_BGR2RGBA);
std::lock_guard<std::mutex> lock(_mutex);
- _is_working = true;
// If detection loss has happended for 2 seconds - 60 is 30fps * 2 - while in maximum zoom-in
// then change the current state to zoom-out.
adjustPreview(cv_image, _cv_image);
- _is_working = false;
-
_image_data.width = _cv_image.cols;
_image_data.height = _cv_image.rows;
_image_data.byte_per_pixel = _cv_image.channels();
void user_callback(unsigned char *buffer, unsigned int width, unsigned int height, unsigned int bytes_per_pixel,
void *user_data)
{
- cv::Mat result(cv::Size(width, height), CV_MAKETYPE(CV_8U, 4), buffer);
+ cv::Mat result(cv::Size(width, height), CV_MAKETYPE(CV_8U, 3), buffer);
+
+ cv::cvtColor(result, result, cv::COLOR_BGR2RGB);
singleo_util_visualizer_2d(result, NULL);
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imgbuf);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, imgbuf);
return texid;
}
tparam.color[3] = 1.0f;
tparam.upsidedown = upsidedown;
- if (tex->format == pixfmt_fourcc('Y', 'U', 'Y', 'V'))
- tparam.textype = 4;
-
draw_2d_texture_in(&tparam);
return SINGLEO_ERROR_NONE;
void DrawImage(cv::Mat &source)
{
- cv::cvtColor(source, source, cv::COLOR_RGBA2BGR);
-
std::vector<int> qualityType;
std::vector<uchar> buff;
qualityType.push_back(cv::IMWRITE_JPEG_QUALITY);
captex.texid = texid;
captex.width = texw;
captex.height = texh;
- captex.format = pixfmt_fourcc('R', 'G', 'B', 'A');
+ captex.format = pixfmt_fourcc('R', 'G', 'B', '3');
float scale = (float) win_h / (float) texh;