12

AR实时求解数独 |Mixlab混合现实

 4 years ago
source link: https://mp.weixin.qq.com/s?__biz=MzA3MDgyMjMwMA%3D%3D&%3Bmid=2649941350&%3Bidx=1&%3Bsn=d9788ccd880793d778d66880cf6ed029
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

7RZnqaR.gif!mobile

首先,什么是WebAssembly?

我们需要知道它到底是什么!

WebAssembly是一种可以让C/C++这些非JavaScript语言编写的代码在浏览器上运行,是一种在web上运行二进制文件的技术标准。

就前端来说,它因为支持了更多的语言,进而可以创造出更多的可能。就后端来说,配置过Opencv或其他C++库的小伙伴都知道,一个环境的部署会有多么的繁琐以及对各种库的高依赖性。

通过这种技术手段,我们就可以通过Js在浏览器上十分简单的调用Opencv的函数库,实现人脸识别、数字识别等功能。

Suduko solver

这是一个Suduko(数独)解算器的项目,通过Rust调用Opencv,Tensorflow的函数库实现实时的识别解算,非常有趣。

mIZr6rJ.png!mobile

在图像中定位数独谜题,解决谜题然后将解决方案呈现回原始图像的步骤

核心步骤:

1、利用自适应阈值函数定位轮廓边缘,生成黑白图像

ZRrIfmj.jpg!mobile

2、通过提取轮廓,找出为数独网格的四边形轮廓

7BVjq2f.png!mobile

3、利用逆透视变换,将侧放的网格渲染成正方形的网格

FRNJr23.png!mobile

4、剔除网格线

yqa6fiF.png!mobile

5、利用卷积神经网络识别数字

e22qymq.jpg!mobile

6、利用基于Rust语言编写的程序,求解数独

use sudoku::Sudoku;

// Sudokus can be created from &str's in both block or line formats or directly from bytes.

// here, an example in line format

let sudoku_line = "...2...633....54.1..1..398........9....538....3........263..5..5.37....847...1...";

let sudoku = Sudoku::from_str_line(sudoku_line).unwrap();

// Solve, print or convert the sudoku to another format

if let Some(solution) = sudoku.solve_unique() {

// print the solution in line format

println!("{}", solution);

// or return it as a byte array

let cell_contents: [u8; 81] = solution.to_bytes();

}

7、进行透视变换,将求解后的数字投影回图像上

NRBrIfN.jpg!mobile

就这样,一个涵盖Opencv、tensorflow、Rust、JS等技术的project就完成了,最终经过测试,整体处理时间大约在 70毫秒

Docker的联合创始人之一Solomon Hykes在Twitter上这样评价过WASI,体现了WebAssembly的价值。

FJrieuZ.jpg!mobile

更多 # 跨学科·人工智能  

粉丝福利  

进群查看,有惊喜!

N3IfQny.jpg!mobile


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK