Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

resizing a picture in opencv?

Tags:

python

opencv

i am writing a face dection program in opencv. And this is the error code below:

result = img[rects[0]:rects[1], rects[2]:rects[3]] 
result = cv2.resize(result, (100,100)) 

img is our original picture and the first step is croping out our rigion of interest into result. The second step is resize to 100*100 pixels.

the error is:

result = cv2.resize(result, (100,100))
error: ..\..\..\src\opencv\modules\imgproc\src\imgwarp.cpp:1725: error: (-215) ssize.area() > 0

Hope someone can help me. Thanks a lot.

like image 929
user1510711 Avatar asked Apr 03 '13 10:04

user1510711


People also ask

How do I resize an image in Python?

To resize an image, you call the resize() method on it, passing in a two-integer tuple argument representing the width and height of the resized image. The function doesn't modify the used image; it instead returns another Image with the new dimensions.

How do I change the resolution of an image in OpenCV Python?

The first step is to create an object of the DNN superresolution class. This is followed by the reading and setting of the model, and finally, the image is upscaled. We have provided the Python and C++ codes below. You can replace the value of the model_path variable with the path of the model that you want to use.

What is scaling in OpenCV?

In this tutorial, you will learn how to resize an image using OpenCV and the cv2. resize function. Scaling, or simply resizing, is the process of increasing or decreasing the size of an image in terms of width and height.


1 Answers

Had the same error in python ,found that image was empty so check whether imread worked or not by using imshow or checking it for NULL then use cv2.resize .

like image 190
aabhas Avatar answered Sep 29 '22 12:09

aabhas