I use opencv to crop images and I'd like to save them to the models, I load the file directly to computeLogoFromMemoryFILE
where it is processed, from there how can I save the image to TempImage
model?
views.py:
form = myForm(request.FILES)
if form.is_valid():
cropped_image = computeLogoFromMemoryFILE(request.FILES.get('logo'))
# ...
temp_image = TempImage.objects.create(image=?)
cv2:
# (np == numpy)
def computeLogoFromMemoryFILE(logo):
logo.seek(0)
image = cv2.imdecode(np.fromstring(logo.read(), np.uint8), cv2.IMREAD_UNCHANGED)
cropped_img = crop_image(image)
cropped_image variable is an opencv array :
array([[ 52, 218, 255],
[ 52, 218, 255],
[ 52, 218, 255],
...,
[ 52, 218, 255],
[ 52, 218, 255],
[ 52, 218, 255]]...], dtype=uint8)
How should I proceed?