Opencv 如何检测计算机/笔记本电脑';图像中的屏幕是什么?

Opencv 如何检测计算机/笔记本电脑';图像中的屏幕是什么?,opencv,computer-vision,object-detection,image-segmentation,edge-detection,Opencv,Computer Vision,Object Detection,Image Segmentation,Edge Detection,我试图检测显示器的屏幕,无论是电脑还是笔记本电脑 第一张图片是原始图像,第二张图片用我想在图像中检测的矩形区域的点标记。 我曾试图通过使用opencv的cv2.findContours来获取屏幕,但没有任何帮助。在这本书中,他有屏幕正面的图片,但我大部分都是有角度的图片(视频),所以抓取好的轮廓和定义屏幕会崩溃 我用于查找屏幕的代码: import numpy as np import imutils import cv2 from PIL import Image args = {

我试图检测显示器的屏幕,无论是电脑还是笔记本电脑

第一张图片是原始图像,第二张图片用我想在图像中检测的矩形区域的点标记。 我曾试图通过使用opencv的
cv2.findContours
来获取屏幕,但没有任何帮助。在这本书中,他有屏幕正面的图片,但我大部分都是有角度的图片(视频),所以抓取好的轮廓和定义屏幕会崩溃

我用于查找屏幕的代码:

import numpy as np
import imutils
import cv2

from PIL import Image 
args = {
   'query': '/Users/PC/Desktop/screendetect/mm.jpeg'
}
class dotdict(dict):
    def __getattr__(self, name):
        return self[name]

args = dotdict(args)
# load the query image, compute the ratio of the old height
# to the new height, clone it, and resize it
image = cv2.imread(args["query"])
ratio = image.shape[0] / 300.0
orig = image.copy()
image = imutils.resize(image, height = 300)

# convert the image to grayscale, blur it, and find edges
# in the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.bilateralFilter(gray, 11, 17, 17)
edged = cv2.Canny(gray, 30, 200)

# find contours
cnts = cv2.findContours(edged.copy(), cv2.RETR_TREE, 
cv2.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(cnts)
cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:100]
screenCnt = None

# loop over our contours
for c in cnts:
# approximate the contour
    peri = cv2.arcLength(c, True)
    approx = cv2.approxPolyDP(c, 0.03 * peri, True)

    # if our approximated contour has four points, then
    # we can assume that we have found our screen
    if len(approx):
        screenCnt = approx
        break

# draw a rectangle around the screen
orig = image.copy()
d = cv2.drawContours(image, [screenCnt], -1, (0, 255, 0), 1)
cv2.imwrite("/Users/PC/Desktop/screendetect/test_good.jpg", d)
# cv2.waitKey(0)

在其他测试图像中将只有一个显示器,所以我只需要找到一个屏幕。解决这类问题的最佳方法是什么?

如果你可以使用标记,可以考虑使用ARUCO标记吗?在角度图像的情况下,你可能还需要先玩单应性。如果你可以使用标记,可以考虑使用ARUCO标记吗?在角度图像的情况下,您可能还需要首先处理单应性。