OpenCV resize fails on large image with “error: (-215) ssize.area() > 0 in function cv::resize”
I'm using OpenCV 3.0.0 and Python 3.4.3 to process a very large RGB image (107162,79553,3). While I'm trying to resize it using the following code:
import cv2
image = cv2.resize(img, (0,0), fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)
I had this error message coming up :
"cv2.error: C:opencv-3.0.0sourcemodulesimgprocsrcimgwarp.cpp:3208: error: (-215) ssize.area() > 0 in function cv::resize"
I'm certain there is image content in the image array because I can save them into small tiles in jpg format. When I try to resize just a small part of the image, there is no problem and I end up with correctly resized image. (Taking a rather big chunk (50000,50000,3) still won't work, but it will work on a (10000,10000,3) chunk)
I'm wondering what could cause this problem and how I can solve this?
Thanks
image opencv python-3.x image-processing opencv3.0
add a comment |
I'm using OpenCV 3.0.0 and Python 3.4.3 to process a very large RGB image (107162,79553,3). While I'm trying to resize it using the following code:
import cv2
image = cv2.resize(img, (0,0), fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)
I had this error message coming up :
"cv2.error: C:opencv-3.0.0sourcemodulesimgprocsrcimgwarp.cpp:3208: error: (-215) ssize.area() > 0 in function cv::resize"
I'm certain there is image content in the image array because I can save them into small tiles in jpg format. When I try to resize just a small part of the image, there is no problem and I end up with correctly resized image. (Taking a rather big chunk (50000,50000,3) still won't work, but it will work on a (10000,10000,3) chunk)
I'm wondering what could cause this problem and how I can solve this?
Thanks
image opencv python-3.x image-processing opencv3.0
4
guess: integer range is +/- 2.147.483.647 while cols x rows ist 8.525.058.586 in your example.So PROBABLY there is an integer overflow within cv::resize. You could test this by testing image sizes around cols x rows == 2.147.483.647
– Micka
Aug 13 '15 at 19:23
Hey Micka, you're right !! It works on (46340,46340,3) but not (46341,46341,3). Does that mean changing int to int64 should solve the problem?
– user3667217
Aug 13 '15 at 19:59
I dont know where inside of cv::resize the area is computed. I think you have to have a look at opencv resize source code...
– Micka
Aug 13 '15 at 20:43
Where can I find this file in macos, I didn't find any file which has similar name ?
– Iem-Prog
Mar 25 '18 at 13:06
add a comment |
I'm using OpenCV 3.0.0 and Python 3.4.3 to process a very large RGB image (107162,79553,3). While I'm trying to resize it using the following code:
import cv2
image = cv2.resize(img, (0,0), fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)
I had this error message coming up :
"cv2.error: C:opencv-3.0.0sourcemodulesimgprocsrcimgwarp.cpp:3208: error: (-215) ssize.area() > 0 in function cv::resize"
I'm certain there is image content in the image array because I can save them into small tiles in jpg format. When I try to resize just a small part of the image, there is no problem and I end up with correctly resized image. (Taking a rather big chunk (50000,50000,3) still won't work, but it will work on a (10000,10000,3) chunk)
I'm wondering what could cause this problem and how I can solve this?
Thanks
image opencv python-3.x image-processing opencv3.0
I'm using OpenCV 3.0.0 and Python 3.4.3 to process a very large RGB image (107162,79553,3). While I'm trying to resize it using the following code:
import cv2
image = cv2.resize(img, (0,0), fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)
I had this error message coming up :
"cv2.error: C:opencv-3.0.0sourcemodulesimgprocsrcimgwarp.cpp:3208: error: (-215) ssize.area() > 0 in function cv::resize"
I'm certain there is image content in the image array because I can save them into small tiles in jpg format. When I try to resize just a small part of the image, there is no problem and I end up with correctly resized image. (Taking a rather big chunk (50000,50000,3) still won't work, but it will work on a (10000,10000,3) chunk)
I'm wondering what could cause this problem and how I can solve this?
Thanks
image opencv python-3.x image-processing opencv3.0
image opencv python-3.x image-processing opencv3.0
edited Aug 13 '15 at 19:10
user3667217
asked Aug 13 '15 at 19:00
user3667217user3667217
1,4571924
1,4571924
4
guess: integer range is +/- 2.147.483.647 while cols x rows ist 8.525.058.586 in your example.So PROBABLY there is an integer overflow within cv::resize. You could test this by testing image sizes around cols x rows == 2.147.483.647
– Micka
Aug 13 '15 at 19:23
Hey Micka, you're right !! It works on (46340,46340,3) but not (46341,46341,3). Does that mean changing int to int64 should solve the problem?
– user3667217
Aug 13 '15 at 19:59
I dont know where inside of cv::resize the area is computed. I think you have to have a look at opencv resize source code...
– Micka
Aug 13 '15 at 20:43
Where can I find this file in macos, I didn't find any file which has similar name ?
– Iem-Prog
Mar 25 '18 at 13:06
add a comment |
4
guess: integer range is +/- 2.147.483.647 while cols x rows ist 8.525.058.586 in your example.So PROBABLY there is an integer overflow within cv::resize. You could test this by testing image sizes around cols x rows == 2.147.483.647
– Micka
Aug 13 '15 at 19:23
Hey Micka, you're right !! It works on (46340,46340,3) but not (46341,46341,3). Does that mean changing int to int64 should solve the problem?
– user3667217
Aug 13 '15 at 19:59
I dont know where inside of cv::resize the area is computed. I think you have to have a look at opencv resize source code...
– Micka
Aug 13 '15 at 20:43
Where can I find this file in macos, I didn't find any file which has similar name ?
– Iem-Prog
Mar 25 '18 at 13:06
4
4
guess: integer range is +/- 2.147.483.647 while cols x rows ist 8.525.058.586 in your example.So PROBABLY there is an integer overflow within cv::resize. You could test this by testing image sizes around cols x rows == 2.147.483.647
– Micka
Aug 13 '15 at 19:23
guess: integer range is +/- 2.147.483.647 while cols x rows ist 8.525.058.586 in your example.So PROBABLY there is an integer overflow within cv::resize. You could test this by testing image sizes around cols x rows == 2.147.483.647
– Micka
Aug 13 '15 at 19:23
Hey Micka, you're right !! It works on (46340,46340,3) but not (46341,46341,3). Does that mean changing int to int64 should solve the problem?
– user3667217
Aug 13 '15 at 19:59
Hey Micka, you're right !! It works on (46340,46340,3) but not (46341,46341,3). Does that mean changing int to int64 should solve the problem?
– user3667217
Aug 13 '15 at 19:59
I dont know where inside of cv::resize the area is computed. I think you have to have a look at opencv resize source code...
– Micka
Aug 13 '15 at 20:43
I dont know where inside of cv::resize the area is computed. I think you have to have a look at opencv resize source code...
– Micka
Aug 13 '15 at 20:43
Where can I find this file in macos, I didn't find any file which has similar name ?
– Iem-Prog
Mar 25 '18 at 13:06
Where can I find this file in macos, I didn't find any file which has similar name ?
– Iem-Prog
Mar 25 '18 at 13:06
add a comment |
10 Answers
10
active
oldest
votes
So it turns out that the problem comes from one line in modulesimgprocsrcimgwarp.cpp
:
CV_Assert( ssize.area() > 0 );
When the product of rows and columns of the image to be resized is larger than 2^31, ssize.area() results in a negative number. This appears to be a bug in OpenCV and hopefully will be fixed in the future release. A temporary fix is to build OpenCV with this line commented out. While not ideal, it works for me.
And I just recently found out that the above applies only to image whose width is larger than height. For images with height larger than width, it's the following line that causes error:
CV_Assert( dsize.area() > 0 );
So this has to be commented out as well.
6
How do you change this line of code? Where is file located?
– Zvonimir Peran
Aug 31 '16 at 8:34
1
Yes this is great but where can we find the file
– Hack-R
Feb 9 '17 at 18:00
2
Was a solution to fix this line of code ever posted/found?
– Laughing Horse
Apr 11 '17 at 3:46
Please tell where is the respective file located.
– Haris
Apr 22 '17 at 19:23
Just search 'imgwrap.cpp' in the main directory '/' and you'll find the file!
– Ubdus Samad
May 16 '17 at 11:27
add a comment |
Turns out for me this error was actually telling the truth - I was trying to resize a Null image, which was usually the 'last' frame of a video file, so the assertion was valid.
Now I have an extra step before attempting the resize operation, which is to do the assertion myself:
def getSizedFrame(width, height):
"""Function to return an image with the size I want"""
s, img = self.cam.read()
# Only process valid image frames
if s:
img = cv2.resize(img, (width, height), interpolation = cv2.INTER_AREA)
return s, img
Now I don't see the error.
I don't think this is the general case. This error does occur with valid images because of the OpenCV bug.
– Hack-R
Feb 9 '17 at 18:01
This is the first hit on Google and this should be upvoted!! Check your imgs before starting commenting out the openCV code, I had exactly same problem while parsing dozens of images in preprocessing.
– Jan Sila
Oct 17 '17 at 14:01
add a comment |
I know this is a very old thread but I had the same problem which was due spaces in the images names.
e.g.
Image name: "hello o.jpg"
weirdly, by removing the spaces the function worked just fine.
Image name: "hello_o.jpg"
add a comment |
For me the following work-around worked:
- split the array up into smaller sub arrays
- resize the sub arrays
- merge the sub arrays again
Here the code:
def split_up_resize(arr, res):
"""
function which resizes large array (direct resize yields error (addedtypo))
"""
# compute destination resolution for subarrays
res_1 = (res[0], res[1]/2)
res_2 = (res[0], res[1] - res[1]/2)
# get sub-arrays
arr_1 = arr[0 : len(arr)/2]
arr_2 = arr[len(arr)/2 :]
# resize sub arrays
arr_1 = cv2.resize(arr_1, res_1, interpolation = cv2.INTER_LINEAR)
arr_2 = cv2.resize(arr_2, res_2, interpolation = cv2.INTER_LINEAR)
# init resized array
arr = np.zeros((res[1], res[0]))
# merge resized sub arrays
arr[0 : len(arr)/2] = arr_1
arr[len(arr)/2 :] = arr_2
return arr
It didn't work for me, I'm getting the same error! "error: (-215) ssize.area() > 0 in function resize". Note: I had to modify ur code since indexing value must be an integer. "Use // instead of / ".
– Iem-Prog
Mar 25 '18 at 13:26
add a comment |
This type of error also takes place because the resize is unable to get the image in simple
the directory of the image may be wrong.In my case I left the forward slash during providing the location of file and this error took place after I put the slash problem was solved.
add a comment |
Turns out I had a .csv file at the end of the folder from which I was reading all the images.
Once I deleted that it worked alright
Make sure that it's all images and that you don't have any other type of file
add a comment |
In my case I did a wrong modification in the image.
I was able to find the problem checking the image shape.
print img.shape
add a comment |
Also pay attention to the object type of your numpy array, converting it using .astype('uint8')
resolved the issue for me.
add a comment |
I am having OpenCV version 3.4.3 on MacOS.
I was getting the same error as above.
I changed my code from
frame = cv2.resize(frame, (0,0), fx=0.5, fy=0.5)
to
frame = cv2.resize(frame, None, fx=0.5, fy=0.5)
Now its working fine for me.
add a comment |
I was working with 3 files: The python script, the image, and the trained model.
Everything worked when I moved these 3 files into their own folder instead of in the directory with the other python scripts.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31996367%2fopencv-resize-fails-on-large-image-with-error-215-ssize-area-0-in-funct%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
10 Answers
10
active
oldest
votes
10 Answers
10
active
oldest
votes
active
oldest
votes
active
oldest
votes
So it turns out that the problem comes from one line in modulesimgprocsrcimgwarp.cpp
:
CV_Assert( ssize.area() > 0 );
When the product of rows and columns of the image to be resized is larger than 2^31, ssize.area() results in a negative number. This appears to be a bug in OpenCV and hopefully will be fixed in the future release. A temporary fix is to build OpenCV with this line commented out. While not ideal, it works for me.
And I just recently found out that the above applies only to image whose width is larger than height. For images with height larger than width, it's the following line that causes error:
CV_Assert( dsize.area() > 0 );
So this has to be commented out as well.
6
How do you change this line of code? Where is file located?
– Zvonimir Peran
Aug 31 '16 at 8:34
1
Yes this is great but where can we find the file
– Hack-R
Feb 9 '17 at 18:00
2
Was a solution to fix this line of code ever posted/found?
– Laughing Horse
Apr 11 '17 at 3:46
Please tell where is the respective file located.
– Haris
Apr 22 '17 at 19:23
Just search 'imgwrap.cpp' in the main directory '/' and you'll find the file!
– Ubdus Samad
May 16 '17 at 11:27
add a comment |
So it turns out that the problem comes from one line in modulesimgprocsrcimgwarp.cpp
:
CV_Assert( ssize.area() > 0 );
When the product of rows and columns of the image to be resized is larger than 2^31, ssize.area() results in a negative number. This appears to be a bug in OpenCV and hopefully will be fixed in the future release. A temporary fix is to build OpenCV with this line commented out. While not ideal, it works for me.
And I just recently found out that the above applies only to image whose width is larger than height. For images with height larger than width, it's the following line that causes error:
CV_Assert( dsize.area() > 0 );
So this has to be commented out as well.
6
How do you change this line of code? Where is file located?
– Zvonimir Peran
Aug 31 '16 at 8:34
1
Yes this is great but where can we find the file
– Hack-R
Feb 9 '17 at 18:00
2
Was a solution to fix this line of code ever posted/found?
– Laughing Horse
Apr 11 '17 at 3:46
Please tell where is the respective file located.
– Haris
Apr 22 '17 at 19:23
Just search 'imgwrap.cpp' in the main directory '/' and you'll find the file!
– Ubdus Samad
May 16 '17 at 11:27
add a comment |
So it turns out that the problem comes from one line in modulesimgprocsrcimgwarp.cpp
:
CV_Assert( ssize.area() > 0 );
When the product of rows and columns of the image to be resized is larger than 2^31, ssize.area() results in a negative number. This appears to be a bug in OpenCV and hopefully will be fixed in the future release. A temporary fix is to build OpenCV with this line commented out. While not ideal, it works for me.
And I just recently found out that the above applies only to image whose width is larger than height. For images with height larger than width, it's the following line that causes error:
CV_Assert( dsize.area() > 0 );
So this has to be commented out as well.
So it turns out that the problem comes from one line in modulesimgprocsrcimgwarp.cpp
:
CV_Assert( ssize.area() > 0 );
When the product of rows and columns of the image to be resized is larger than 2^31, ssize.area() results in a negative number. This appears to be a bug in OpenCV and hopefully will be fixed in the future release. A temporary fix is to build OpenCV with this line commented out. While not ideal, it works for me.
And I just recently found out that the above applies only to image whose width is larger than height. For images with height larger than width, it's the following line that causes error:
CV_Assert( dsize.area() > 0 );
So this has to be commented out as well.
edited Feb 14 '17 at 5:09
answered Aug 16 '15 at 7:21
user3667217user3667217
1,4571924
1,4571924
6
How do you change this line of code? Where is file located?
– Zvonimir Peran
Aug 31 '16 at 8:34
1
Yes this is great but where can we find the file
– Hack-R
Feb 9 '17 at 18:00
2
Was a solution to fix this line of code ever posted/found?
– Laughing Horse
Apr 11 '17 at 3:46
Please tell where is the respective file located.
– Haris
Apr 22 '17 at 19:23
Just search 'imgwrap.cpp' in the main directory '/' and you'll find the file!
– Ubdus Samad
May 16 '17 at 11:27
add a comment |
6
How do you change this line of code? Where is file located?
– Zvonimir Peran
Aug 31 '16 at 8:34
1
Yes this is great but where can we find the file
– Hack-R
Feb 9 '17 at 18:00
2
Was a solution to fix this line of code ever posted/found?
– Laughing Horse
Apr 11 '17 at 3:46
Please tell where is the respective file located.
– Haris
Apr 22 '17 at 19:23
Just search 'imgwrap.cpp' in the main directory '/' and you'll find the file!
– Ubdus Samad
May 16 '17 at 11:27
6
6
How do you change this line of code? Where is file located?
– Zvonimir Peran
Aug 31 '16 at 8:34
How do you change this line of code? Where is file located?
– Zvonimir Peran
Aug 31 '16 at 8:34
1
1
Yes this is great but where can we find the file
– Hack-R
Feb 9 '17 at 18:00
Yes this is great but where can we find the file
– Hack-R
Feb 9 '17 at 18:00
2
2
Was a solution to fix this line of code ever posted/found?
– Laughing Horse
Apr 11 '17 at 3:46
Was a solution to fix this line of code ever posted/found?
– Laughing Horse
Apr 11 '17 at 3:46
Please tell where is the respective file located.
– Haris
Apr 22 '17 at 19:23
Please tell where is the respective file located.
– Haris
Apr 22 '17 at 19:23
Just search 'imgwrap.cpp' in the main directory '/' and you'll find the file!
– Ubdus Samad
May 16 '17 at 11:27
Just search 'imgwrap.cpp' in the main directory '/' and you'll find the file!
– Ubdus Samad
May 16 '17 at 11:27
add a comment |
Turns out for me this error was actually telling the truth - I was trying to resize a Null image, which was usually the 'last' frame of a video file, so the assertion was valid.
Now I have an extra step before attempting the resize operation, which is to do the assertion myself:
def getSizedFrame(width, height):
"""Function to return an image with the size I want"""
s, img = self.cam.read()
# Only process valid image frames
if s:
img = cv2.resize(img, (width, height), interpolation = cv2.INTER_AREA)
return s, img
Now I don't see the error.
I don't think this is the general case. This error does occur with valid images because of the OpenCV bug.
– Hack-R
Feb 9 '17 at 18:01
This is the first hit on Google and this should be upvoted!! Check your imgs before starting commenting out the openCV code, I had exactly same problem while parsing dozens of images in preprocessing.
– Jan Sila
Oct 17 '17 at 14:01
add a comment |
Turns out for me this error was actually telling the truth - I was trying to resize a Null image, which was usually the 'last' frame of a video file, so the assertion was valid.
Now I have an extra step before attempting the resize operation, which is to do the assertion myself:
def getSizedFrame(width, height):
"""Function to return an image with the size I want"""
s, img = self.cam.read()
# Only process valid image frames
if s:
img = cv2.resize(img, (width, height), interpolation = cv2.INTER_AREA)
return s, img
Now I don't see the error.
I don't think this is the general case. This error does occur with valid images because of the OpenCV bug.
– Hack-R
Feb 9 '17 at 18:01
This is the first hit on Google and this should be upvoted!! Check your imgs before starting commenting out the openCV code, I had exactly same problem while parsing dozens of images in preprocessing.
– Jan Sila
Oct 17 '17 at 14:01
add a comment |
Turns out for me this error was actually telling the truth - I was trying to resize a Null image, which was usually the 'last' frame of a video file, so the assertion was valid.
Now I have an extra step before attempting the resize operation, which is to do the assertion myself:
def getSizedFrame(width, height):
"""Function to return an image with the size I want"""
s, img = self.cam.read()
# Only process valid image frames
if s:
img = cv2.resize(img, (width, height), interpolation = cv2.INTER_AREA)
return s, img
Now I don't see the error.
Turns out for me this error was actually telling the truth - I was trying to resize a Null image, which was usually the 'last' frame of a video file, so the assertion was valid.
Now I have an extra step before attempting the resize operation, which is to do the assertion myself:
def getSizedFrame(width, height):
"""Function to return an image with the size I want"""
s, img = self.cam.read()
# Only process valid image frames
if s:
img = cv2.resize(img, (width, height), interpolation = cv2.INTER_AREA)
return s, img
Now I don't see the error.
answered Sep 9 '16 at 7:22
Kelton.TembyKelton.Temby
404511
404511
I don't think this is the general case. This error does occur with valid images because of the OpenCV bug.
– Hack-R
Feb 9 '17 at 18:01
This is the first hit on Google and this should be upvoted!! Check your imgs before starting commenting out the openCV code, I had exactly same problem while parsing dozens of images in preprocessing.
– Jan Sila
Oct 17 '17 at 14:01
add a comment |
I don't think this is the general case. This error does occur with valid images because of the OpenCV bug.
– Hack-R
Feb 9 '17 at 18:01
This is the first hit on Google and this should be upvoted!! Check your imgs before starting commenting out the openCV code, I had exactly same problem while parsing dozens of images in preprocessing.
– Jan Sila
Oct 17 '17 at 14:01
I don't think this is the general case. This error does occur with valid images because of the OpenCV bug.
– Hack-R
Feb 9 '17 at 18:01
I don't think this is the general case. This error does occur with valid images because of the OpenCV bug.
– Hack-R
Feb 9 '17 at 18:01
This is the first hit on Google and this should be upvoted!! Check your imgs before starting commenting out the openCV code, I had exactly same problem while parsing dozens of images in preprocessing.
– Jan Sila
Oct 17 '17 at 14:01
This is the first hit on Google and this should be upvoted!! Check your imgs before starting commenting out the openCV code, I had exactly same problem while parsing dozens of images in preprocessing.
– Jan Sila
Oct 17 '17 at 14:01
add a comment |
I know this is a very old thread but I had the same problem which was due spaces in the images names.
e.g.
Image name: "hello o.jpg"
weirdly, by removing the spaces the function worked just fine.
Image name: "hello_o.jpg"
add a comment |
I know this is a very old thread but I had the same problem which was due spaces in the images names.
e.g.
Image name: "hello o.jpg"
weirdly, by removing the spaces the function worked just fine.
Image name: "hello_o.jpg"
add a comment |
I know this is a very old thread but I had the same problem which was due spaces in the images names.
e.g.
Image name: "hello o.jpg"
weirdly, by removing the spaces the function worked just fine.
Image name: "hello_o.jpg"
I know this is a very old thread but I had the same problem which was due spaces in the images names.
e.g.
Image name: "hello o.jpg"
weirdly, by removing the spaces the function worked just fine.
Image name: "hello_o.jpg"
answered May 30 '17 at 10:50
WandererWanderer
338519
338519
add a comment |
add a comment |
For me the following work-around worked:
- split the array up into smaller sub arrays
- resize the sub arrays
- merge the sub arrays again
Here the code:
def split_up_resize(arr, res):
"""
function which resizes large array (direct resize yields error (addedtypo))
"""
# compute destination resolution for subarrays
res_1 = (res[0], res[1]/2)
res_2 = (res[0], res[1] - res[1]/2)
# get sub-arrays
arr_1 = arr[0 : len(arr)/2]
arr_2 = arr[len(arr)/2 :]
# resize sub arrays
arr_1 = cv2.resize(arr_1, res_1, interpolation = cv2.INTER_LINEAR)
arr_2 = cv2.resize(arr_2, res_2, interpolation = cv2.INTER_LINEAR)
# init resized array
arr = np.zeros((res[1], res[0]))
# merge resized sub arrays
arr[0 : len(arr)/2] = arr_1
arr[len(arr)/2 :] = arr_2
return arr
It didn't work for me, I'm getting the same error! "error: (-215) ssize.area() > 0 in function resize". Note: I had to modify ur code since indexing value must be an integer. "Use // instead of / ".
– Iem-Prog
Mar 25 '18 at 13:26
add a comment |
For me the following work-around worked:
- split the array up into smaller sub arrays
- resize the sub arrays
- merge the sub arrays again
Here the code:
def split_up_resize(arr, res):
"""
function which resizes large array (direct resize yields error (addedtypo))
"""
# compute destination resolution for subarrays
res_1 = (res[0], res[1]/2)
res_2 = (res[0], res[1] - res[1]/2)
# get sub-arrays
arr_1 = arr[0 : len(arr)/2]
arr_2 = arr[len(arr)/2 :]
# resize sub arrays
arr_1 = cv2.resize(arr_1, res_1, interpolation = cv2.INTER_LINEAR)
arr_2 = cv2.resize(arr_2, res_2, interpolation = cv2.INTER_LINEAR)
# init resized array
arr = np.zeros((res[1], res[0]))
# merge resized sub arrays
arr[0 : len(arr)/2] = arr_1
arr[len(arr)/2 :] = arr_2
return arr
It didn't work for me, I'm getting the same error! "error: (-215) ssize.area() > 0 in function resize". Note: I had to modify ur code since indexing value must be an integer. "Use // instead of / ".
– Iem-Prog
Mar 25 '18 at 13:26
add a comment |
For me the following work-around worked:
- split the array up into smaller sub arrays
- resize the sub arrays
- merge the sub arrays again
Here the code:
def split_up_resize(arr, res):
"""
function which resizes large array (direct resize yields error (addedtypo))
"""
# compute destination resolution for subarrays
res_1 = (res[0], res[1]/2)
res_2 = (res[0], res[1] - res[1]/2)
# get sub-arrays
arr_1 = arr[0 : len(arr)/2]
arr_2 = arr[len(arr)/2 :]
# resize sub arrays
arr_1 = cv2.resize(arr_1, res_1, interpolation = cv2.INTER_LINEAR)
arr_2 = cv2.resize(arr_2, res_2, interpolation = cv2.INTER_LINEAR)
# init resized array
arr = np.zeros((res[1], res[0]))
# merge resized sub arrays
arr[0 : len(arr)/2] = arr_1
arr[len(arr)/2 :] = arr_2
return arr
For me the following work-around worked:
- split the array up into smaller sub arrays
- resize the sub arrays
- merge the sub arrays again
Here the code:
def split_up_resize(arr, res):
"""
function which resizes large array (direct resize yields error (addedtypo))
"""
# compute destination resolution for subarrays
res_1 = (res[0], res[1]/2)
res_2 = (res[0], res[1] - res[1]/2)
# get sub-arrays
arr_1 = arr[0 : len(arr)/2]
arr_2 = arr[len(arr)/2 :]
# resize sub arrays
arr_1 = cv2.resize(arr_1, res_1, interpolation = cv2.INTER_LINEAR)
arr_2 = cv2.resize(arr_2, res_2, interpolation = cv2.INTER_LINEAR)
# init resized array
arr = np.zeros((res[1], res[0]))
# merge resized sub arrays
arr[0 : len(arr)/2] = arr_1
arr[len(arr)/2 :] = arr_2
return arr
edited Mar 13 '17 at 15:29
Community♦
11
11
answered Mar 10 '17 at 7:28
Oli BlumOli Blum
1,1571122
1,1571122
It didn't work for me, I'm getting the same error! "error: (-215) ssize.area() > 0 in function resize". Note: I had to modify ur code since indexing value must be an integer. "Use // instead of / ".
– Iem-Prog
Mar 25 '18 at 13:26
add a comment |
It didn't work for me, I'm getting the same error! "error: (-215) ssize.area() > 0 in function resize". Note: I had to modify ur code since indexing value must be an integer. "Use // instead of / ".
– Iem-Prog
Mar 25 '18 at 13:26
It didn't work for me, I'm getting the same error! "error: (-215) ssize.area() > 0 in function resize". Note: I had to modify ur code since indexing value must be an integer. "Use // instead of / ".
– Iem-Prog
Mar 25 '18 at 13:26
It didn't work for me, I'm getting the same error! "error: (-215) ssize.area() > 0 in function resize". Note: I had to modify ur code since indexing value must be an integer. "Use // instead of / ".
– Iem-Prog
Mar 25 '18 at 13:26
add a comment |
This type of error also takes place because the resize is unable to get the image in simple
the directory of the image may be wrong.In my case I left the forward slash during providing the location of file and this error took place after I put the slash problem was solved.
add a comment |
This type of error also takes place because the resize is unable to get the image in simple
the directory of the image may be wrong.In my case I left the forward slash during providing the location of file and this error took place after I put the slash problem was solved.
add a comment |
This type of error also takes place because the resize is unable to get the image in simple
the directory of the image may be wrong.In my case I left the forward slash during providing the location of file and this error took place after I put the slash problem was solved.
This type of error also takes place because the resize is unable to get the image in simple
the directory of the image may be wrong.In my case I left the forward slash during providing the location of file and this error took place after I put the slash problem was solved.
answered Mar 10 at 17:07
darkemperorVKOdarkemperorVKO
111
111
add a comment |
add a comment |
Turns out I had a .csv file at the end of the folder from which I was reading all the images.
Once I deleted that it worked alright
Make sure that it's all images and that you don't have any other type of file
add a comment |
Turns out I had a .csv file at the end of the folder from which I was reading all the images.
Once I deleted that it worked alright
Make sure that it's all images and that you don't have any other type of file
add a comment |
Turns out I had a .csv file at the end of the folder from which I was reading all the images.
Once I deleted that it worked alright
Make sure that it's all images and that you don't have any other type of file
Turns out I had a .csv file at the end of the folder from which I was reading all the images.
Once I deleted that it worked alright
Make sure that it's all images and that you don't have any other type of file
answered Jan 6 '18 at 9:31
empoleonrocksempoleonrocks
21
21
add a comment |
add a comment |
In my case I did a wrong modification in the image.
I was able to find the problem checking the image shape.
print img.shape
add a comment |
In my case I did a wrong modification in the image.
I was able to find the problem checking the image shape.
print img.shape
add a comment |
In my case I did a wrong modification in the image.
I was able to find the problem checking the image shape.
print img.shape
In my case I did a wrong modification in the image.
I was able to find the problem checking the image shape.
print img.shape
answered Jun 28 '18 at 14:34
ThomioThomio
711714
711714
add a comment |
add a comment |
Also pay attention to the object type of your numpy array, converting it using .astype('uint8')
resolved the issue for me.
add a comment |
Also pay attention to the object type of your numpy array, converting it using .astype('uint8')
resolved the issue for me.
add a comment |
Also pay attention to the object type of your numpy array, converting it using .astype('uint8')
resolved the issue for me.
Also pay attention to the object type of your numpy array, converting it using .astype('uint8')
resolved the issue for me.
answered Dec 10 '18 at 1:18
AttilaAttila
11
11
add a comment |
add a comment |
I am having OpenCV version 3.4.3 on MacOS.
I was getting the same error as above.
I changed my code from
frame = cv2.resize(frame, (0,0), fx=0.5, fy=0.5)
to
frame = cv2.resize(frame, None, fx=0.5, fy=0.5)
Now its working fine for me.
add a comment |
I am having OpenCV version 3.4.3 on MacOS.
I was getting the same error as above.
I changed my code from
frame = cv2.resize(frame, (0,0), fx=0.5, fy=0.5)
to
frame = cv2.resize(frame, None, fx=0.5, fy=0.5)
Now its working fine for me.
add a comment |
I am having OpenCV version 3.4.3 on MacOS.
I was getting the same error as above.
I changed my code from
frame = cv2.resize(frame, (0,0), fx=0.5, fy=0.5)
to
frame = cv2.resize(frame, None, fx=0.5, fy=0.5)
Now its working fine for me.
I am having OpenCV version 3.4.3 on MacOS.
I was getting the same error as above.
I changed my code from
frame = cv2.resize(frame, (0,0), fx=0.5, fy=0.5)
to
frame = cv2.resize(frame, None, fx=0.5, fy=0.5)
Now its working fine for me.
answered Jan 2 at 23:34
BiranchiBiranchi
9,00720104139
9,00720104139
add a comment |
add a comment |
I was working with 3 files: The python script, the image, and the trained model.
Everything worked when I moved these 3 files into their own folder instead of in the directory with the other python scripts.
add a comment |
I was working with 3 files: The python script, the image, and the trained model.
Everything worked when I moved these 3 files into their own folder instead of in the directory with the other python scripts.
add a comment |
I was working with 3 files: The python script, the image, and the trained model.
Everything worked when I moved these 3 files into their own folder instead of in the directory with the other python scripts.
I was working with 3 files: The python script, the image, and the trained model.
Everything worked when I moved these 3 files into their own folder instead of in the directory with the other python scripts.
answered Feb 22 at 0:06
Shane RooneyShane Rooney
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31996367%2fopencv-resize-fails-on-large-image-with-error-215-ssize-area-0-in-funct%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
guess: integer range is +/- 2.147.483.647 while cols x rows ist 8.525.058.586 in your example.So PROBABLY there is an integer overflow within cv::resize. You could test this by testing image sizes around cols x rows == 2.147.483.647
– Micka
Aug 13 '15 at 19:23
Hey Micka, you're right !! It works on (46340,46340,3) but not (46341,46341,3). Does that mean changing int to int64 should solve the problem?
– user3667217
Aug 13 '15 at 19:59
I dont know where inside of cv::resize the area is computed. I think you have to have a look at opencv resize source code...
– Micka
Aug 13 '15 at 20:43
Where can I find this file in macos, I didn't find any file which has similar name ?
– Iem-Prog
Mar 25 '18 at 13:06