我有这张林线作物的图像。我需要找到作物对齐的大致方向。我试图获取图像的霍夫线,然后找到角度分布的模式。
我一直在关注本关于裁剪线的教程,但是在该教程中,裁剪线很稀疏。这里它们是密集的,经过灰度、模糊和使用精明的边缘检测后,这就是我得到的
import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('drive/MyDrive/tree/sample.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
gauss = cv2.GaussianBlur(gray, (3,3), 3)
plt.figure(figsize=(15,15))
plt.subplot(1,2,1)
plt.imshow(gauss)
gscale = cv2.Canny(gauss, 80, 140)
plt.subplot(1,2,2)
plt.imshow(gscale)
plt.show()
Run Code Online (Sandbox Code Playgroud)
(左侧未经canny处理的模糊图像,左侧经过canny预处理的图像)

之后,我按照教程将预处理后的图像“骨架化”
size = np.size(gscale)
skel = np.zeros(gscale.shape, np.uint8)
ret, gscale = cv2.threshold(gscale, 128, 255,0)
element = cv2.getStructuringElement(cv2.MORPH_CROSS, (3,3))
done = False
while not done:
eroded = cv2.erode(gscale, element)
temp = cv2.dilate(eroded, element)
temp = cv2.subtract(gscale, temp)
skel = cv2.bitwise_or(skel, temp)
gscale = …Run Code Online (Sandbox Code Playgroud) 在 arch linux 中启动 mariadb 会导致 systemctl 日志上显示“无法打开和锁定权限表:表‘mysql.servers’不存在”
所以,你知道当你在浏览器上使用 django Rest api 访问视图时,你会得到一个 html 页面,当你发送类似 ajax 请求的内容时,你会得到 json 吗?我试图弄清楚如何搞乱 vite 的代理设置,但我找不到一个像样的文档。我想将“/”重定向到“http://localhost:8000/api”,但确实发生了奇怪的行为。如果我在 localhost:8000/api 上有一条路由,我可以这样做:
//vite.config.js
export default defineConfig({
plugins: [vue()],
server: {
proxy: {
//Focus here
'/api': {
target: 'http://localhost:8000',
changeOrigin: true,
rewrite: (path) => { console.log(path); return path.replace('/^\/api/', '') }
}
}
}
})
Run Code Online (Sandbox Code Playgroud)
//todo-component.vue
export default {
data() {
return {
todos: []
}
},
components: {
TodoElement
},
beforeCreate() {
//Focus here as well
this.axios.get('/api').then((response) => {
this.todos = response.data
})
.catch((e) => {
console.error(e)
}) …Run Code Online (Sandbox Code Playgroud)