我想imshow
用opencv
我保存在数据库中的 blob 类型。
我试过这样:
import numpy as np
def check(self):
self.create_database("resimler.db")
sorgu="select RESİM from resimler where ID=?"
ıd=3
self.cursor.execute(sorgu,(ıd,))
blob_data=self.cursor.fetchone()[0]
nparr = np.fromstring(blob_data, np.uint8)
img_np = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
image=cv2.resize(img_np,(130,100))
cv2.imshow("data",image)
我收到此错误错误:(-215) ssize.width > 0 && ssize.height > 0 in function cv::resize
我这样放数据
def kaydet(self,resim,ad):
sorgu="insert into resimler (RESİM,AD) values (?,?)"
self.cursor.execute(sorgu,[sqlite3.Binary(resim),ad])
self.baglantı.commit()
图片,我从opencv的视频捕获中得到的,以这种方式
while True:
(_, im) = self.cap.read()
gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 4)
for (x, y, w, h) in faces:
cv2.rectangle(im, (x, y), (x + w, y + h), (255, 0, 0), 2)
face = gray[y:y + h, x:x + w]
face_resize = cv2.resize(face, (width, height))
cv2.imshow("img",face_resize)
resimler.append(face_resize)
cv2.imshow('OpenCV', im)
sayıcı+=1
if cv2.waitKey(1) == ord('q'):
cv2.destroyAllWindows()
self.show_frame()
self.main()
break
if sayıcı%100==0:
resim=resimler[len(resimler)//2]
cv2.imshow("resim",resim)
self.create_database("resimler.db")
self.kaydet(resim,"resim")
self.kapat()
print("kaydedildi")
self.main()
break