当我点击返回或暂停或取消显示的广告时,我有一个游戏,当玩家死亡时,我想控制展示广告。每次游戏结束后,插页式广告都会展示。
这是我处理广告的课程:
#include "image-processing.h"
void compute_edge_map_via_lab(cv::Mat image, cv::Mat edge_map) {
int rows = image.rows;
int cols = image.cols;
//convert bgr to lab
cv::Mat image_lab;
cv::cvtColor(image, image_lab, CV_BGR2Lab);
//split lab
std::vector<cv::Mat> image_lab_split(3);
cv::split(image_lab, image_lab_split);
//run sobel x and y on lab sets
std::vector<cv::Mat> image_lab_split_dx(3), image_lab_split_dy(3);
for (int i = 0; i < 3; i++)
{
cv::Sobel(image_lab_split[i], image_lab_split_dx[i], CV_32FC1, 1, 0, 3);
cv::Sobel(image_lab_split[i], image_lab_split_dy[i], CV_32FC1, 0, 1, 3);
}
//-----------------------------------------------------------------------------
//compute magnitude = term_a + term_b
// = sqrt(Lx^2 + Ly^2) + sqrt(2(ax^2 + ay^2 + bx^2 + by^2))
//-----------------------------------------------------------------------------
//compute sqrt(Lx^2 + Ly^2)
cv::Mat Lx_squared = cv::Mat(cv::Size(cols, rows), CV_32FC1),
Ly_squared = cv::Mat(cv::Size(cols, rows), CV_32FC1);
cv::pow(image_lab_split_dx[0], 2, Lx_squared);
cv::pow(image_lab_split_dy[0], 2, Ly_squared);
//compute term_a
cv::Mat term_a = cv::Mat(cv::Size(cols, rows), CV_32FC1);
term_a = Lx_squared + Ly_squared;
cv::sqrt(term_a, term_a);
//compute sqrt(2(ax^2 + ay^2 + bx^2 + by^2))
cv::Mat ax_squared = cv::Mat(cv::Size(cols, rows), CV_32FC1),
ay_squared = cv::Mat(cv::Size(cols, rows), CV_32FC1),
bx_squared = cv::Mat(cv::Size(cols, rows), CV_32FC1),
by_squared = cv::Mat(cv::Size(cols, rows), CV_32FC1);
cv::pow(image_lab_split_dx[1], 2, ax_squared);
cv::pow(image_lab_split_dy[1], 2, ay_squared);
cv::pow(image_lab_split_dx[2], 2, bx_squared);
cv::pow(image_lab_split_dy[2], 2, by_squared);
//compute term_b
cv::Mat term_b = 2 * (ax_squared + ay_squared + bx_squared + by_squared);
cv::sqrt(term_b, term_b);
//compute magnitude
edge_map = term_a + term_b;
}
void compute_local_minima(cv::Mat magnitude, cv::Mat markers) {
}
非常感谢