使用Python和openCV进行打印缺陷检测并发送信号 [英] Defect Detection of a Print Using Python and openCV and Sending a Signal

查看:488
本文介绍了使用Python和openCV进行打印缺陷检测并发送信号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用图像处理来查找书写有缺陷的笔.参考图像和缺陷图像如下所示.

I'm using image processing to find defective pens with their writing. Reference image and a defective image is shown below.

我使用python和openCV,并且使用XOR(减法)操作获得了下面的图像.

I used python and openCV and I got below image using XOR (subtraction) operation.

现在,我想在检测到此类故障笔时发送数字信号.我该怎么办?

Now I want to send a digital signal when such a defective pen is detected. How can I do that?

推荐答案

嗯,有多种方法可以实现PLC与python脚本之间的通信.通过使用snap7模块,您可以通过pip安装西门子S7-1200之间的通讯,并取得了一些成功.它使用起来非常简单,我可以读/写输入,输出,标记....我不确定,但我认为LOGO具有与S7类似的通讯协议.您可以查看此链接 Snap7-LOGO .您也可以只谷歌"snap7 python"并阅读文档.

Well there are different ways to achieve communication between a PLC and your python script. I have had some succes with communication between a Siemens S7-1200 with using the snap7 module which you can install via pip. It is quite simple to use and I could read/write inputs, outputs, markers,... I am not sure but I think that LOGO has a similar communitaion protocol as the S7. You could check out this link Snap7 - LOGO. You can also just google "snap7 python" and read the documentation.

还有另一个名为libnodave的模块.我没有尝试过,但听说有人对此感到成功.您也可以在Google上搜索并阅读文档.

There is another module called libnodave. I have not tried it but I heard people had succses with it. You can also google it and read the documentation.

我也很成功地交流了没有以太网端口的S7-200(旧PLC).我使用了Arduino和具有24V rele输出的I/O屏蔽.您可以通过串行通信轻松地与Arduino通信,并且该解决方案可以明确地用于LOGO.请注意,Arduino不是一个强大的解决方案,它可能会受到附近高压设备的干扰.您可以制作一个法拉第笼来抑制干扰,尽管我从未尝试过.

I have also had succses with communicating the S7-200 (older PLC) which doesn't have an ethernet port. I used Arduino and an I/O shield that has 24V rele outputs. You can easily communicate with Arduino via Serial communication and this solution could definetly be used for LOGO. Note that Arduino is not an robust solution and it could get interferences from near high voltage devices. You could make a faradei cage to supress the interference though I have never tried it.

您还可以尝试使用一个可以从几乎所有设备获取信号并与PLC进行通信的机载模块,但是它们可能很昂贵.

You can also try an on-machine modules that can get signal from almost anything and communicate with PLC but theye are probably expensive.

希望它可以帮助您找到解决方案,或者至少扩大您的领域.如果您愿意,我可以发布用于arduino通信或snap7库通信的示例代码.干杯!

Hope it helps a bit or at least widen your area on finding the solution. If you wish, I can post sample codes for arduino communication or the snap7 library communication. Cheers!

注意:这种问题最好在信号处理堆栈交换

Note: This kind of question would be better on Signal Processing Stack Exchange

这篇关于使用Python和openCV进行打印缺陷检测并发送信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆