【问题标题】:How to convent brg to hsv in video catching如何在视频捕捉中将 bgr 转换为 hsv
【发布时间】:2022-12-20 23:37:29
【问题描述】:

我有一台 Mac,我为 CS GO 创建了我的机器人。我的代码:

import numpy as np
import cv2
from mss import mss
from PIL import Image

bounding_box = {'top': 100, 'left': 0, 'width': 2050, 'height': 600}

#variable sct is the mss() function
sct = mss()

#main function
def screen_record():
   while True:
       sct_img = sct.grab(bounding_box)
       
       #BGR to HSV
       hsv_img = cv2.cvtColor(sct_img, cv2.COLOR_BGR2HSV)

       cv2.imshow('screen', np.array(sct_img))

       if (cv2.waitKey(1) & 0xFF) == ord('q'):
           cv2.destroyAllWindows()
           break

错误:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    screen_record()
  File "/Users/yuriy/Desktop/AI/videocapture.py", line 23, in screen_record
    hsv_img = cv2.cvtColor(sct_img, cv2.COLOR_BGR2HSV)
cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'cvtColor'
> Overload resolution failed:
>  - src is not a numpy array, neither a scalar
>  - Expected Ptr<cv::UMat> for argument 'src'

而且,我想将 brg 格式转换为 hsv,因为机器人搜索颜色会更容易。请帮我!

我将尝试在 Google 中搜索,但我没有找到任何东西。

【问题讨论】:

    标签: python opencv python-imaging-library mss


    【解决方案1】:

    对不起,我忘了。编程语言是python

    【讨论】:

      猜你喜欢
      • 2021-09-18
      • 2013-06-13
      • 1970-01-01
      • 2017-07-01
      • 2014-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多