【问题标题】:what does roi_gray function do in opencvroi_gray函数在opencv中做了什​​么
【发布时间】:2020-06-18 20:55:31
【问题描述】:

我正在做一个人脸检测程序,但我不了解以下功能:

roi_gray = gray[y:y+h, x:x+w]
roi_color = img[y:y+h, x:x+w]

【问题讨论】:

  • roi 代表感兴趣区域;除此之外,我不知道还有什么不清楚的......
  • 而且不是函数,与opencv无关。这只是 numpy 切片

标签: python-3.x


【解决方案1】:

正如 @Berriel 和 @Miki 在 cmets 中提到的。 ROI 代表感兴趣的区域。

roi_gray = gray[y:y+h, x:x+w]

这会分割灰色数组。它基本上选择从yy+h 的行和从xx+w 的列。这与roi_color 的工作方式相同。

所以基本上你选择的灰色像素的高度从y开始一直到y+h(因为h表示高度)。并选择从x 像素开始一直到x+w 像素的宽度(这里的w 表示宽度)。

我希望这会有所帮助! 这是roiwikipedia链接

【讨论】:

    【解决方案2】:

    当你通过书写声明面的坐标时

    for (x,y,w,h) in faces:
        roi_gray=gray[y:y+h,x:x+w]    #This particular code will return the cropped face from the image.
        roi_color = img[y:y+h, x:x+w] #This particular code will return the details of the image that u will recive after getting the co-ordinates of the image.
    

    【讨论】:

      猜你喜欢
      • 2015-07-17
      • 1970-01-01
      • 2020-11-04
      • 2017-07-27
      • 2018-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多