简体   繁体   English

JavaScript:检测画布中的形状

[英]JavaScript: Detecting shape in canvas

I found out app called https://skinmotion.com/ and for learning purposes, I would like to create my own, web version of the app.我发现了一个名为https://skinmotion.com/ 的应用程序,出于学习目的,我想创建自己的 Web 版本的应用程序。

Web application work as follows. Web 应用程序工作如下。 It asks user for permission to access camera.它要求用户获得访问相机的权限。 After that, video is caputer.之后,视频被捕获。 Once every second, image is taken from the stream and processed.每秒一次,从流中获取图像并进行处理。 During this process, I look for soundwave patern in the image.在这个过程中,我在图像中寻找声波模式。

If the pattern is found, video recording stops and some action is executed.如果找到该模式,则视频录制停止并执行某些操作。

Example of pattern - https://www.shutterstock.com/cs/image-vector/panorama-mini-earthquake-wave-on-white-788490724 .模式示例 - https://www.shutterstock.com/cs/image-vector/panorama-mini-earthquake-wave-on-white-788490724

Idealy, it should work like with QR codes - even small qrcode is detected, it should not depend on rotation and scaling.理想情况下,它应该像使用二维码一样工作 - 即使检测到很小的二维码,它也不应该依赖于旋转和缩放。

I am no computer vision expert, this field is fairly new to me.我不是计算机视觉专家,这个领域对我来说相当陌生。 I need some help.我需要帮助。 Which is the best way to do this?这样做的最佳方法是什么?

Should I train my own Tensorflow dataset and use tensorflow.js?我应该训练我自己的 Tensorflow 数据集并使用 tensorflow.js 吗? Or is there easier and more "light weight" option?或者有更简单、更“轻量”的选择吗?

My problem is, I could not find or come up with algorithm for processing the captured image to make as "comparable" as possible - scale it up, rotate, threshold to white and black colors, etc.我的问题是,我找不到或想出算法来处理捕获的图像以使其尽可能“具有可比性” - 将其放大,旋转,阈值到白色和黑色等。

I hope that after this transformation, resemble.js could be used to compare "original" and "captured" image.我希望经过这种转换后,可以使用like.js来比较“原始”和“捕获”图像。

Thank you in advance.先感谢您。

With Deep Learning通过深度学习

If there are certain waves patterns to be recognized, a classification model can be written using tensorfow.js.如果要识别某些波浪模式,则可以使用 tensorfow.js 编写分类模型。

However if the model is to identify waves pattern in general, it can be more complex.然而,如果模型要识别一般的波浪模式,它可能会更复杂。 An object detection model is to be used.将使用对象检测模型

Without deep learning没有深度学习

Adding to the complexity, would be detecting the waveform and play an audio from it.增加复杂性的是检测波形并从中播放音频。 In this latter case, the image can be read byte by byte.在后一种情况下,可以逐字节读取图像。 The wave graph is drawn with a certain color that is different from the background of the image.波形图是用与图像背景不同的某种颜色绘制的。 The area of interest can be identified and an array representing the wav form can be generated.可以识别感兴趣的区域并生成表示 wav 形式的数组。

Then to play the audio from the array, it can be done as shown here然后从数组播放音频,这是可以做到如图所示这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM