小编VaF*_*ncy的帖子

OpenCV:适合检测到的边缘

我通过使用canny边缘检测来检测水波的边缘.但是,我想为这条边拟合一条曲线.这可能在OpenCV中吗?

这是边缘检测前的图像: 边缘检测前的图像.

这是边缘检测操作的结果: 检测结果

代码是从OpenCV教程中的示例复制而来的:

import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('BW.JPG',0)
edges = cv2.Canny(img,100,200)

plt.plot(1),plt.imshow(edges,cmap = 'gray')
plt.title('WAVE')
plt.show()
Run Code Online (Sandbox Code Playgroud)

python opencv curve-fitting edge-detection

6
推荐指数
1
解决办法
4195
查看次数

如何通过检测按键来打破Python中的这个循环

from subprocess import call
try:
    while True:
        call (["raspivid -n -b 2666666.67 -t 5000 -o test.mp4"],shell=True)
        call (["raspivid -n -b 2666666.67 -t 5000 -o test1.mp4"],shell=True)
except KeyboardInterrupt:
    pass
Run Code Online (Sandbox Code Playgroud)

当我按任何按钮时,我打算让它打破循环.但是我尝试了许多方法来打破它们并且没有一个工作.

python python-2.7 raspberry-pi

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

使用 Tkinter 中的按钮终止线程

在我的 GUI 代码中,我尝试通过单击一个按钮来同时运行循环 1 和循环 2。因此,我曾经Thread实现过这一点。但我也尝试通过单击另一个按钮来阻止它,但失败了。在stackoverflow上搜索后,我发现没有直接杀死 的方法Thread。这是代码的一部分:

def loop1():
    while True:
        call (["raspivid -n -op 150 -w 640 -h 480 -b 2666666.67 -t 5000 -o test.mp4"],shell=True)
        call (["raspivid -n -op 150 -w 640 -h 480 -b 2666666.67 -t 5000 -o test1.mp4"],shell=True)

def loop2():
    while True:
        call (["arecord -D plughw:1 --duration=5 -f cd -vv rectest.wav"],shell=True)
        call (["arecord -D plughw:1 --duration=5 -f cd -vv rectest1.wav"],shell=True)

def combine():
    Thread(target = loop1).start()
    Thread(target = loop2).start()

def stop():
    Thread(target = loop1).terminate() …
Run Code Online (Sandbox Code Playgroud)

python multithreading tkinter multiprocessing raspberry-pi

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