Opencv-เป็นภาษาไพธอนยังไงจำไม้สีชมพูอยู่ในภาพ?

0

คำถาม

ยังไงฉันรู้จัก ไม้สีชมพู อยู่ในภาพ? ฉันเคยดรหัสนี้แต่ฉันไม่ได้เจอสีชมพูเล็กวู้ดอยู่ในภาพได้ที่นี่

ฉันหวังว่าถ้าผมให้ช่างภาพเป็นข้อมูลที่แสดงผลของ สีชมพู วู้ดจะถูกจำได้

นอกจากนี้วิธีการทำคุณมีข้อแนะนำสำหรับจำได้สีชมพูรอวู้ด????

นำเข้าข้อมูล:

ส่งออกได้คาดหวัง(ด้วยตนเองทำเครื่องหมาย)

รหัส:

import numpy as np


import cv2
from cv2 import *
im = cv2.imread(imagePath)

im = cv2.bilateralFilter(im,9,75,75)
im = cv2.fastNlMeansDenoisingColored(im,None,10,10,7,21)
hsv_img = cv2.cvtColor(im, cv2.COLOR_BGR2HSV)   # HSV image


COLOR_MIN = np.array([233, 88, 233],np.uint8)       # HSV color code lower and upper bounds
COLOR_MAX = np.array([241, 82, 240],np.uint8)       # color pink 

frame_threshed = cv2.inRange(hsv_img, COLOR_MIN, COLOR_MAX)     # Thresholding image
imgray = frame_threshed
ret,thresh = cv2.threshold(frame_threshed,127,255,0)
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
print(contours)
for cnt in contours:
    x,y,w,h = cv2.boundingRect(cnt)
    print(x,y)
    cv2.rectangle(im,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imwrite("extracted.jpg", im)

ส่งออกรหัส:

print(contours)
()

ปัญหาคือมสีชมพูรอนะวู้ดมันไม่จำ

1

คำตอบที่ดีที่สุด

1

เปลี่ยนของคุณ HSV ด้านล่างและสูงขอบเขตที่ด้านล่างนี้:

COLOR_MIN = np.array([130,0,220],np.uint8)    
COLOR_MAX = np.array([170,255,255],np.uint8)  

enter image description here

2021-11-22 21:03:20

ขอบคุณสำหรับคำตอบของคุณ นั่นเป็นคำตอบ ขอถามคำถามนึงทำไมคุณถึงเลือกสีนี้? [170,255,255]
M. Farzalizadeh

แค่เล่นกับพวกนั้น HSV ผมสามารถบอกได้นะปกติ HSV ช่วง:H=0-360 เอ=0-100 และวี=0-100. Opencv HSV ช่วง:H:0-179 เอ:0-255,V:0-255.แตกต่างโปรแกรมใช้ต่างออกค่าสำหรับ HSV. เรียนที่คล้ายกันปัญหา[stackoverflow.com/questions/10948589/...
Nishani Kasineshan

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................