python 您所在的位置:网站首页 真人图像 python

python

2024-02-16 10:56| 来源: 网络整理| 查看: 265

我正在尝试检测图像是卡通还是真人。我在谷歌上搜索并实现了提到的两种算法,但都无法准确预测图像是相机拍摄的人还是卡通/动漫角色

这是我的脚本:

detectCartoon1 使用拉普拉斯方法检测图像是否为人。 (我认为相机拍摄的照片质量会较低,因此这很容易奏效)。但它失败了 - 它给了我大量的误报。

detectCartoon2 使用了其他人在堆栈溢出时提到的方法。它认为我们将滤镜应用于卡通后,不会有太多变化;但是如果我们应用从较低质量的相机/网络摄像头拍摄的照片,将会有很多变化。同样,大量误报。

我一直在 Google 上搜索其他方法,或者试图想出我自己的方法,但我就是想不出任何方法。如果您能就此主题提供任何帮助,我将不胜感激。

谢谢!

import cv2 import numpy def detectCartoon1(imagePath): img_before = cv2.imread(imagePath) img_after = 0 gray = cv2.GaussianBlur(img_before, (3, 3), 0, 0, cv2.BORDER_DEFAULT) gray = cv2.cvtColor(gray, cv2.COLOR_BGR2GRAY) img_after = cv2.Laplacian(gray, cv2.CV_64F) img_after = cv2.convertScaleAbs(img_after) return numpy.mean(img_after) def detectCartoon2(imagePath): img_before = cv2.imread(imagePath) img_after = 0 for i in range(1, 31, 2): img_after = cv2.bilateralFilter(img_before, i, i*2, i/2) img_after = cv2.cvtColor(img_after, cv2.COLOR_HSV2BGR_FULL) img_before = cv2.cvtColor(img_before, cv2.COLOR_HSV2BGR_FULL) return numpy.mean(img_before - img_after) from os import listdir for img in listdir('Save'): img = 'Save\\' + img dc1 = detectCartoon1(img) dc2 = detectCartoon2(img) print('Img: ' + img + ' detectCartoon1: ' + str(dc1) + ' detectCartoon2: ' + str(dc2))

最佳答案

这是关于您的问题的好论文:http://www.uv.es/~tzveta/invwork.pdf

关于python - 使用 OpenCV 检测图像是卡通还是真人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22264469/



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有