Dec-18-2020, 07:07 PM
Dec-19-2020, 10:46 AM
What is your OS and opencv-python Version? I have 4.4
Output:pip3 show opencv-python
Name: opencv-python
Version: 4.4.0.46
Summary: Wrapper package for OpenCV python bindings.
Home-page: https://github.com/skvark/opencv-python
Author: None
Author-email: None
License: MIT
Location: /home/brian/.local/lib/python3.8/site-packages
Requires: numpy
Dec-19-2020, 01:08 PM
Hello, it shows me this:
update: I ran this command:
When I try to run the python_code.py file, I get this error:
I installed again opencv:
Error:UbuntuUser@ubuntu:~/Desktop/PyQT$ pip3 show opencv-python
WARNING: Package(s) not found: opencv-python
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:
Error:QObject::moveToThread: Current thread (0x21735e0) is not the object's thread (0x28819c0).
Cannot move to target thread (0x21735e0)
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/mojito/.local/lib/python3.8/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.
Aborted (core dumped)
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
and
maybe you should use pip3 install ...
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
Output: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'
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:
in order to open the tiff files. I get these errors:
Error:MainThread INFO 2020-12-20 04:05:11,775 TaurusRootLogger: Using PyQt5 (v5.15.2 with Qt 5.15.2 and Python 3.8.5)
Traceback (most recent call last):
File "OrthoView_with_rasterio.py", line 678, in <module>
window = OrthoView()
File "OrthoView_with_rasterio.py", line 530, in __init__
self.updateFrame()
File "OrthoView_with_rasterio.py", line 570, in updateFrame
self.getFrame()
File "OrthoView_with_rasterio.py", line 540, in getFrame
self.img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
TypeError: Expected Ptr<cv::UMat> for argument 'src'
Any ideas?Dec-21-2020, 10:48 AM
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
Dec-21-2020, 06:58 PM
Ok, it works partially, when using small .tiff files around 10 MB, but with 400-500 MB, I have this error:
Error:cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-h2062vqd/opencv/modules/core/src/alloc.cpp:73: error: (-4:Insufficient memory) Failed to allocate 24586133472 bytes in function 'OutOfMemoryError'
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.
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.