日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python识别图片坐标查看器_Opencv/python图像处理后如何获取检测区域的坐标

發(fā)布時間:2024/2/28 python 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python识别图片坐标查看器_Opencv/python图像处理后如何获取检测区域的坐标 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

這是我使用的代碼。最后,我不得不重新調(diào)整我的數(shù)據(jù)幀,但只是為了更好地閱讀。我認(rèn)為我的代碼有很多可能的改進(jìn),但是我很高興我的代碼行為足夠好地滿足我的需要。在import cv2

import numpy as np

import pandas as pd

img = cv2.imread('full_snap.png')

"""

some of my blue pixels

R: between 98 and 128

G: between 176 and 211

B: between 255

h: between 210 and 200

s: between 100 and 48

v: between 68 and 100

hsv/2 in opencv and opencv uses BGR not RGB

"""

blue_MIN = np.array([255, 176, 98])

blue_MAX = np.array([255, 211, 128])

"""

https://pythonprogramming.net/color-filter-python-opencv-tutorial/

"""

# find the blue pixels and save it in frame_threshed

frame_threshed = cv2.inRange(img, blue_MIN, blue_MAX)

# find contours in the thresholded image

cnts = cv2.findContours(frame_threshed.copy(), cv2.RETR_EXTERNAL,

cv2.CHAIN_APPROX_SIMPLE)

cnts = cnts[0] if imutils.is_cv2() else cnts[1]

#print("cnts", cnts)

i = len(cnts)

print("i", i)

# we know we're gonna have x rows of data, where x is the product of

# board_width * board_height

numberOfRows = 81

# check if the length of cnts are euqal to the number of rows/ number of tiles

# then go further

# TODO

# create x,y data

# df = pd.DataFrame(index=np.arange(numberOfRows, 0), columns=('x', 'y'))

d = []

print("d", d)

print(type(d))

for c in cnts:

# compute the center of the contour

M = cv2.moments(c)

cX = int(M["m10"] / M["m00"])

cY = int(M["m01"] / M["m00"])

# fill the data with the coords

d.append({'tilenumber': i, 'X-Value': cX, 'Y-Value': cY})

# decrease i to go backwards, because tile number 81 is the first contour

i-=1

# draw the center of the shape on the image

cv2.circle(img, (cX, cY), 1, (255, 255, 255), -1)

df = pd.DataFrame(d)

# only for debugging

print("x,y dataframe", df)

cv2.imshow("Image_with_contours",img)

# Destroys all of the HighGUI windows.

cv2.destroyAllWindows()

謝謝大家的幫助!

羅比納圖爾

總結(jié)

以上是生活随笔為你收集整理的python识别图片坐标查看器_Opencv/python图像处理后如何获取检测区域的坐标的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。