小编Ely*_*ium的帖子

从紧密耦合的线和噪声曲线中找到直线

我有这张林线作物的图像。我需要找到作物对齐的大致方向。我试图获取图像的霍夫线,然后找到角度分布的模式。树木作物线

我一直在关注关于裁剪线的教程,但是在该教程中,裁剪线很稀疏。这里它们是密集的,经过灰度、模糊和使用精明的边缘检测后,这就是我得到的

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)

python opencv numpy hough-transform

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

Mysql/mariadb“无法打开和锁定权限表:表‘mysql.servers’不存在”

在 arch linux 中启动 mariadb 会导致 systemctl 日志上显示“无法打开和锁定权限表:表‘mysql.servers’不存在”

mysql mariadb archlinux

4
推荐指数
1
解决办法
5410
查看次数

如何将代理与 vite(vue 前端)和 django Rest 框架一起使用

所以,你知道当你在浏览器上使用 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)

javascript django django-rest-framework vue.js vite

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