【发布时间】:2023-04-06 04:09:01
【问题描述】:
我是一名学习者,我想在 Django 中使用 OpenCV 将彩色图像转换为灰度图像,但我已经厌倦了解决它。当我上传彩色图像时,我会显示原始图像,但是当我无法转换为灰度或二进制图像时,如果有任何可能的解决方案,请给我一个错误。 link
def show(request):
from.models import User
from django.views.decorators.csrf import csrf_exempt, csrf_protect
user=User.objects.all()
p = user[len(user)-1].pic
ptUMat=cv2.cvtColor(p,cv2.COLOR_RGB2GRAY)
o=cv2.imshow('gray image',pt)
#img= cv2.imread(p)
#plt=cv2.cvtColor(img,cv2.COLOR_BAYER_BG2BGR)
#q=request.FILES['img']
#ima=binary(pic=q)
#ima.save()
print(o.url)
return render(request,'binaryimage.html',{'pic':o.url})
【问题讨论】:
-
你确定“p”是彩色图像吗?
标签: django python-3.x opencv django-rest-framework django-views