how to read image from sql opencv

Solutions on MaxInterview for how to read image from sql opencv by the best coders in the world

showing results for - "how to read image from sql opencv"
Sébastien
30 Jan 2019
1#I am reading an image in through cv2.imread() and cropping it (slicedImage). I want to save the result in a database as a blob.
2
3originalImage = cv2.imread(self.imagePath.get())
4    x1coord = int(self.x1.get())
5    y1coord = int(self.y1.get())
6    x2coord = int(self.x2.get())
7    y2coord = int(self.y2.get())
8
9    slicedImage = originalImage[x1coord:y1coord, x2coord:y2coord]
10#How would I do this when this is my SQL statement?
11
12sqlQuery = "UPDATE users SET UserImage="+slicedImage +", PointOfInterest1X=%d, PointOfInterest1Y=%d, " \
13               "PointOfInterest2X=%d, PointOfInterest2Y=%d WHERE Email=%s"
14    inputData = (slicedImage, x1, y1, x2, y2, prevEmail)
15    mycursor.execute(sqlQuery, inputData)