I often switch between Python and MATLAB during analysis phase of my code development, this time when I was trying to access a specific coordinates of a picture captured from webcam using a simple MATLAB and Python script, I realized that the image size for the same picture (captured from same webcam but with different code (MATLAB and Python)) is different. Same picture in MATLAB was of size (720, 1280, 3)
and in Python was (480, 640, 3)
. Any explanation to this will be really helpful!
Please find the code I used for MATLAB and Python below:
MATLAB:
vid = videoinput('winvideo', 1);
set(vid, 'ReturnedColorSpace', 'RGB');
img = getsnapshot(vid);
disp(size(img))
imshow(img)
Python 3
from cv2 import *
# initialize the camera
cam = VideoCapture(0) # 0 -> index of camera
s, img = cam.read()
print(img.shape)
if s: # frame captured without any errors
namedWindow("cam-test")
imwrite("filename.jpg", img) # save image
imshow("cam-test",img)
waitKey(0)
destroyWindow("cam-test")