小编Dav*_*ran的帖子

Python OpenCV 霍​​夫圆返回 None

None在将霍夫圆合并到我正在尝试编写的跟踪程序的主代码中之前,我试图弄清楚霍夫圆,但除了从圆中取出之外,我似乎什么也得不到 。我使用孟加拉国旗作为我的图像,因为它很简单并且很容易检测到。这是我的代码:

import numpy as np
import cv2


img = cv2.imread('Capture.PNG')

grayput = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

circles = cv2.HoughCircles(grayput, cv2.cv.CV_HOUGH_GRADIENT, 1, 20, param1 =50, param2 =10, minRadius=10, maxRadius=40)
print (circles)

    # need circles 
if circles is not None:
    # convert the coord. to integers
    circles = np.round(circles[0, :]).astype("int")

    # loop over the (x, y) coordinates and radius of the circles
    for (x, y, r) in circles:
        # draw the circle in the output image
        cv2.circle(img, (x, y), r, (0, 0, …
Run Code Online (Sandbox Code Playgroud)

python opencv image-processing hough-transform

5
推荐指数
1
解决办法
5654
查看次数

通过LAN在Raspberry Pi和Arduino之间进行通信

我正在用覆盆子pi进行图像处理,我希望它能够通过LAN与我的arduino交谈,根据pi的指令操纵光束.我见过的唯一的事情是Pi和Arduino之间的直接联系.这对我来说似乎很幼稚,但我试图让他们使用Arduino作为服务器进行通信,使用以太网库进行编程,并通过套接字库将Raspberry Pi作为客户端进行通信.我在路由器上给了他们两个静态IP,并使用下面的代码尝试通过,socket.error: [Errno 113] No route to host但当我的python线来到命令通过特定端口连接到Arduino的IP时,我遇到了.

关于如何更正确地进行此连接的任何想法?我的主要目标是能够通过局域网进行此操作,因此USB连接和直接I2C连接没有帮助,尽管他们肯定会完成工作.

树莓派:

from socket import *
import select

data = None

timeout = 3 # timeout in seconds
msg = "test"

host = "192.168.1.113"
print ("Connecting to " + host)

port = 23

s = socket(AF_INET, SOCK_STREAM)
print "Socket made"

ready = select.select([s],[],[],timeout)


s.connect((host,port))
print("Connection made")

while True:

    if data != None:
        print("[INFO] Sending message...")
        s.sendall(msg)
        data = None
        print("[INFO] Message sent.")
        continue

    if ready[0]:        #if data is actually available …
Run Code Online (Sandbox Code Playgroud)

python sockets networking tcp arduino

3
推荐指数
1
解决办法
1万
查看次数