Internal change

PiperOrigin-RevId: 489486417
This commit is contained in:
MediaPipe Team 2022-11-18 08:51:30 -08:00 committed by Copybara-Service
parent e046982a3c
commit 2f361e2f47
4 changed files with 9 additions and 14 deletions

View File

@ -458,7 +458,6 @@ cc_library(
"//mediapipe/framework/port:integral_types", "//mediapipe/framework/port:integral_types",
"//mediapipe/framework/port:logging", "//mediapipe/framework/port:logging",
"//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_core",
"//mediapipe/framework/port:opencv_highgui",
], ],
) )
@ -739,7 +738,7 @@ cc_test(
"//mediapipe/framework/port:gtest_main", "//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:logging", "//mediapipe/framework/port:logging",
"//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_core",
"//mediapipe/framework/port:opencv_highgui", "//mediapipe/framework/port:opencv_imgcodecs",
"//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:opencv_imgproc",
"//mediapipe/framework/port:status", "//mediapipe/framework/port:status",
"//mediapipe/framework/port:vector", "//mediapipe/framework/port:vector",

View File

@ -791,7 +791,7 @@ void MotionAnalysis::VisualizeBlurAnalysisRegions(cv::Mat* input_view) {
region_flow_computation_->ComputeBlurMask(*input_view, &corner_values, &mask); region_flow_computation_->ComputeBlurMask(*input_view, &corner_values, &mask);
cv::Mat mask_3c; cv::Mat mask_3c;
cv::cvtColor(mask, mask_3c, CV_GRAY2RGB); cv::cvtColor(mask, mask_3c, cv::COLOR_GRAY2RGB);
cv::addWeighted(*input_view, 0.5, mask_3c, 0.5, -128, *input_view); cv::addWeighted(*input_view, 0.5, mask_3c, 0.5, -128, *input_view);
} }

View File

@ -30,6 +30,7 @@
#include "absl/container/node_hash_set.h" #include "absl/container/node_hash_set.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/logging.h"
#include "mediapipe/framework/port/opencv_core_inc.h"
#include "mediapipe/framework/port/opencv_features2d_inc.h" #include "mediapipe/framework/port/opencv_features2d_inc.h"
#include "mediapipe/framework/port/opencv_imgproc_inc.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h"
#include "mediapipe/framework/port/opencv_video_inc.h" #include "mediapipe/framework/port/opencv_video_inc.h"
@ -935,12 +936,13 @@ bool RegionFlowComputation::InitFrame(const cv::Mat& source,
// Area based method best for downsampling. // Area based method best for downsampling.
// For color images to temporary buffer. // For color images to temporary buffer.
cv::Mat& resized = source.channels() == 1 ? dest_frame : *curr_color_image_; cv::Mat& resized = source.channels() == 1 ? dest_frame : *curr_color_image_;
cv::resize(source, resized, resized.size(), 0, 0, CV_INTER_AREA); cv::resize(source, resized, resized.size(), 0, 0, cv::INTER_AREA);
source_ptr = &resized; source_ptr = &resized;
// Resize feature extraction mask if needed. // Resize feature extraction mask if needed.
if (!source_mask.empty()) { if (!source_mask.empty()) {
dest_mask.create(resized.rows, resized.cols, CV_8UC1); dest_mask.create(resized.rows, resized.cols, CV_8UC1);
cv::resize(source_mask, dest_mask, dest_mask.size(), 0, 0, CV_INTER_NN); cv::resize(source_mask, dest_mask, dest_mask.size(), 0, 0,
cv::INTER_NEAREST);
} }
} else if (!source_mask.empty()) { } else if (!source_mask.empty()) {
source_mask.copyTo(dest_mask); source_mask.copyTo(dest_mask);
@ -954,7 +956,7 @@ bool RegionFlowComputation::InitFrame(const cv::Mat& source,
const int dimension = visual_options.tiny_image_dimension(); const int dimension = visual_options.tiny_image_dimension();
data->tiny_image.create(dimension, dimension, type); data->tiny_image.create(dimension, dimension, type);
cv::resize(*source_ptr, data->tiny_image, data->tiny_image.size(), 0, 0, cv::resize(*source_ptr, data->tiny_image, data->tiny_image.size(), 0, 0,
CV_INTER_AREA); cv::INTER_AREA);
} }
if (source_ptr->channels() == 1 && if (source_ptr->channels() == 1 &&
@ -2286,7 +2288,7 @@ void RegionFlowComputation::ExtractFeatures(
// Initialize mask from frame's feature extraction mask, by downsampling and // Initialize mask from frame's feature extraction mask, by downsampling and
// negating the latter mask. // negating the latter mask.
if (!data->mask.empty()) { if (!data->mask.empty()) {
cv::resize(data->mask, mask, mask.size(), 0, 0, CV_INTER_NN); cv::resize(data->mask, mask, mask.size(), 0, 0, cv::INTER_NEAREST);
for (int y = 0; y < mask.rows; ++y) { for (int y = 0; y < mask.rows; ++y) {
uint8* mask_ptr = mask.ptr<uint8>(y); uint8* mask_ptr = mask.ptr<uint8>(y);
for (int x = 0; x < mask.cols; ++x) { for (int x = 0; x < mask.cols; ++x) {
@ -2590,12 +2592,6 @@ void RegionFlowComputation::TrackFeatures(FrameTrackingData* from_data_ptr,
cv::_InputArray input_frame2(data2.pyramid); cv::_InputArray input_frame2(data2.pyramid);
#endif #endif
// Using old c-interface for OpenCV's 2.2 tracker.
CvTermCriteria criteria;
criteria.type = CV_TERMCRIT_EPS | CV_TERMCRIT_ITER;
criteria.max_iter = options_.tracking_options().tracking_iterations();
criteria.epsilon = 0.02f;
feature_track_error_.resize(num_features); feature_track_error_.resize(num_features);
feature_status_.resize(num_features); feature_status_.resize(num_features);
if (use_cv_tracking_) { if (use_cv_tracking_) {

View File

@ -28,7 +28,7 @@
#include "mediapipe/framework/port/gtest.h" #include "mediapipe/framework/port/gtest.h"
#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/logging.h"
#include "mediapipe/framework/port/opencv_core_inc.h" #include "mediapipe/framework/port/opencv_core_inc.h"
#include "mediapipe/framework/port/opencv_highgui_inc.h" #include "mediapipe/framework/port/opencv_imgcodecs_inc.h"
#include "mediapipe/framework/port/opencv_imgproc_inc.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h"
#include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/status.h"
#include "mediapipe/framework/port/vector.h" #include "mediapipe/framework/port/vector.h"