I tried a 400 MB and an 8 MB .tiff, none of which worked.
Thanks
Thanks
Reading coordinates in tiff images using PyQt
|
I tried a 400 MB and an 8 MB .tiff, none of which worked.
Thanks
Dec-19-2020, 10:46 AM
What is your OS and opencv-python Version? I have 4.4
Hello, it shows me this:
I re-install OpenCV with these commands:sudo apt update sudo apt install libopencv-dev python3-opencvand I still get the message above...What is wrong? update: I ran this command: pip install opencv-pythonand it seems opencv to be installed. When I try to run the python_code.py file, I get this error: I use a small .tiff (about 8 MBytes)I installed again opencv: pip install opencv-python-headlessthe above error has gone, but when I continue to see this error: cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-h2062vqd/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'I use Ubuntu 20.04.1 and opencv version: Version: 4.4.0.46
Dec-19-2020, 01:18 PM
whats the output of
pip2 show pip and pip3 show pip maybe you should use pip3 install ...
Dec-19-2020, 01:28 PM
UbuntuUser@ubuntu:~/Desktop/PyQT$ pip2 show pip Command 'pip2' not found, did you mean: command 'pipx' from deb pipx (0.12.3.1-2ubuntu1) command 'nip2' from deb nip2 (8.7.0-1) command 'pip3' from deb python3-pip (20.0.2-5ubuntu1.1) Try: sudo apt install <deb name> UbuntuUser@ubuntu:~/Desktop/PyQT$ pip3 show pip Name: pip Version: 20.3.1 Summary: The PyPA recommended tool for installing Python packages. Home-page: https://pip.pypa.io/ Author: The pip developers Author-email: [email protected] License: MIT Location: /usr/local/lib/python3.8/dist-packages Requires: Required-by:
Dec-19-2020, 01:52 PM
I made a test using lalala.png (that does not exists) and getting the same error message
It is a file not found error (src.empty())
Dec-20-2020, 12:15 PM
I am trying to combine the above code with rasterio https://rasterio.readthedocs.io/en/latest/
in order to open the tiff files. I get these errors: Any ideas?
This is the change, that I have done. Any ideas what is wrong?
def getFrame(self): # <---- line 533 if isTest: fp = r'/home/UbuntuUser/Desktop/UAV_test.tif' # <----- here frame = rasterio.open(fp) # <----- here # OpenCV uses BGR as its default colour order for images self.img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) # <----- here # import pickle # with open(r"_images/sample-holder-test2.pickle", 'rb') as f: # try: # packed = pickle.load(f, encoding='latin1') # except TypeError: # packed = pickle.load(f) # unpacked = np.empty(list(packed.shape)+[3], dtype=np.uint8) # unpacked[:, :, 2] = (packed >> 16) & 0xff # unpacked[:, :, 1] = (packed >> 8) & 0xff # unpacked[:, :, 0] = packed & 0xff # self.img = unpacked else: frame = self.camera.read_attribute('Image').value # for monochrome frames: # self.img = cv2.normalize( # src=frame, dst=None, alpha=0, beta=255, # norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1) # self.img = cv2.cvtColor(self.img, cv2.COLOR_GRAY2BGR) # for color frames: unpacked = np.empty(list(frame.shape)+[3], dtype=np.uint8) unpacked[:, :, 2] = (frame >> 16) & 0xff unpacked[:, :, 1] = (frame >> 8) & 0xff unpacked[:, :, 0] = frame & 0xff self.img = unpacked
Ok, it works partially, when using small .tiff files around 10 MB, but with 400-500 MB, I have this error:
After searching on google there are people that suggest to downsize the image, but in that situation I lose a lot of information. Is here any other way to handle such large images? The VM has 16 GB (real) RAM which is more than enough to handle the 500MB image...am I loosing something here? How can a 500MB causes the need of 24 GB RAM?!!!
Dec-21-2020, 07:20 PM
Your image is not 400-500 MBytes, the compressed image is. What is the actual size of your images (pixel count)?
What is the program doing when it runs out of memory? I looked at some of the code in this post a while back and I saw it loaded an image and then converted to greyscale. I think you would save a lot of memory by converting the file as it loads. |
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
[PySide / PyQt] Offset two images with keyboard increments | carecavoador | 1 | 2,272 |
Sep-09-2023, 12:53 PM Last Post: deanhystad |
|
[Tkinter] Plotting Raster Data / TIFF files on tkinter canvas | RRSCNGP | 0 | 3,199 |
Aug-28-2019, 04:44 AM Last Post: RRSCNGP |