1 Star 0 Fork 1

Jason_Lee/RubiksCube

forked from Jacky/RubiksCube 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
eye.cpp 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
Jacky 提交于 2017-11-15 14:09 . Upload eye.cpp cube.cpp cube.h eye.h
#include "eye.h"
char * getColor(Mat src) {
char colors[9];
Mat gaussian, gray, grad_x, grad_y;
Mat abs_grad_x, abs_grad_y, abs_dst;
resize(src, src, Size(src.size().width/10, src.size().height/10));
imshow("src", src);
//GaussianBlur(src, gaussian, Size(5, 5), 0, 0);
//imshow("gaussian", gaussian);
cvtColor(src, gray, COLOR_BGR2GRAY);
Sobel(gray, grad_x, gray.depth(), 2, 0, 3, 2, 2, BORDER_DEFAULT);
convertScaleAbs(grad_x, abs_grad_x);
//imshow("x", abs_grad_x);
Sobel(gray, grad_y, gray.depth(), 0, 2, 3, 2, 2, BORDER_DEFAULT);
convertScaleAbs(grad_y, abs_grad_y);
//imshow("y", abs_grad_y);
addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.5, 0, abs_dst);
imshow("x+y", abs_dst);
threshold(abs_dst, abs_dst, 0, 255, CV_THRESH_OTSU+CV_THRESH_BINARY);
imshow("threshold", abs_dst);
Mat element = getStructuringElement(MORPH_RECT, Size(5, 5));
Mat closed;
dilate(abs_dst, closed, element);
erode(closed, closed, element);
imshow("closed", closed);
waitKey(0);
return colors;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/Jason-Lee/RubiksCube.git
git@gitee.com:Jason-Lee/RubiksCube.git
Jason-Lee
RubiksCube
RubiksCube
master

搜索帮助