Using OpenCV, Whenever I save an image (from a camera stream) as JPG to the disk. The file size in bytes on the disk differs depending on the JPEG quality as expected.
However, whenever I read the images regardless of the file size on the disk, the memory size remains constant. Is this normal?
Also, there seems to be a massive difference in the disk and memory size of the image. I was expecting a much smaller memory size, somewhat relative to the disk size.
For e.g.
import sys
import cv2
cv2.imwrite('temp.jpg', frame, [int(cv2.IMWRITE_JPEG_QUALITY), 10])
# disk size of temp.jpg is 24kb
image = cv2.imread('temp.jpg')
# memory size is 2.7 mb
cv2.imwrite('temp.jpg', frame, [int(cv2.IMWRITE_JPEG_QUALITY), 90])
# disk size of temp.jpg is 150kb
image = cv2.imread('temp.jpg')
# memory size is still constant at 2.7 mb
This is how I compute the memory size:
print("Image byte size :", round(sys.getsizeof(image) / (1024 * 1024), 2), "mb")