I am using OpenCV in python and I am trying to train a cascade. As a beginner, I wanted some practice in creating cascades, and my cascade is going to detect a rubber.
Here I have a simple positive image, with dimension 665*851 pixels.
To make it easier to train, I want to scale the image down to 50*50 pixels. I tried running this simple code in my python shell:
import cv2 as cv
img = cv.imread('img.jpg')
resized_img = cv.resize(img, (50,50))
cv.imwrite('img1.jpg', img)
This is a lightweight, simple code. My file, img.jpg
is located in the same directory as this python file. The new file does save, however, the size does not change for some reason.
Please tell me if there is something wrong with my code...
Thanks.
You are saving your original image, img
, instead of resized_img
.
Change
cv.imwrite('img1.jpg', img)
to
cv.imwrite('img1.jpg', resized_img)
and your code should work.