-3
在这里,我想读取数据库的形象和我的形象上涂抹一些操作,例如噪音删除发现的....最后我会APPY pytesseract来获取文本期望的字符串或Unicode对象,照片在Django
def GetData(request):
img = Photo.objects.get(id=1)
#wrapper = FileWrapper(open(img.file))
# Read image with opencv
img = cv2.imread(img)
# Apply dilation and erosion to remove some noise
kernel = np.ones((1, 1), np.uint8)
img = cv2.dilate(img, kernel, iterations=1)
img = cv2.erode(img, kernel, iterations=1)
b,g,r = cv2.split(img)
# get b,g,r
rgb_img = cv2.merge([r,g,b])
# switch it to rgb
# Denoising
dst = cv2.fastNlMeansDenoisingColored(img,None,10,10,7,21)
img = cv2.cvtColor(dst, cv2.COLOR_BGR2GRAY)
# Apply threshold to get image with only black and white
img = cv2.adaptiveThreshold(img, 127, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11,2)
new_image = cv2.blur(img, (1, 1))
什么是你的问题? – Antwane
请考虑编辑怎么样,你从django.db进口车型 类照片(models.Model)定义了'Photo'类模型,正是你的堆栈跟踪是什么,等等 – mrnfrancesco
你的问题添加信息: 文件=模型。 ImageField的() 描述= models.CharField(MAX_LENGTH = 255,空=真) UPLOADED_AT = models.DateTimeField(auto_now_add = TRUE) 类元: verbose_name = '照片' verbose_name_plural = '照片' 我想从照片中获取文字 – pratap