Two reasons:
-
- PIP needs to be upgraded
-
- solution = & gt; Command line input:
python -m pip install --upgrade
Maybe it’s really stuck. Then wait slowly ~ or try more times, and you can always solve
Two reasons:
python -m pip install --upgrade
Maybe it’s really stuck. Then wait slowly ~ or try more times, and you can always solve
First of all, first solve the opencv error problem, once up on the error report headache
cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-z4706ql7\opencv\modules\highgui\src\window.cpp:1274: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function ‘cvShowImage’
This version is probably not downloaded well, delete and start again
pip uninstall opencv-python
Then download the command
pip3 install opencv-contrib-python
Nice successfully solved the problem. Of course, there may be errors in the path with Chinese or spaces, and sometimes errors will be reported.
No more code, no more nonsense
import cv2 as cv
import numpy as np
def fill_color_demo(image): #Define the function to fill the color with one click
Img2 = image.copy() # make a copy of the input image
h, w = image.shape[:2] #Get the length and width of the image
mask = np.zeros([h+2, w+2],np.uint8) #mask must be row and column plus 2, and must be uint8 single-channel array, fill the edges need more than 2 pixels, otherwise it will report an error
cv.floodFill(Img2, mask, (100, 100), (127, 127, 127), (100, 100, 100), (50, 50 ,50), cv.FLOODFILL_FIXED_RANGE)
#cv.floodFill, parameter 1,: indicates the input image, parameter 2: indicates the mask of a single channel, parameter 3: indicates the starting point of the flooding algorithm, parameter 4 indicates the color of the fill, and parameters 5,6 indicate the maximum positive and negative difference between the currently observed pixel point and the neighboring pixel points
#x coordinates are from left to right, y coordinates are from top to bottom
cv.imshow("result", Img2) # display the result image
img = cv.imread('. /1.jpg') # read in the image
cv.imshow('input', img) #Show the input image
fill_color_demo(img) #Transfer the input image into the defined fill color function
cv.waitKey(0)
Then there is the result, as shown below
On the left is the original image of input and on the right is the output image. The color is (127127) gray and the coordinates are (100100). You can change the color coordinates as you like. It’s still very fun
Remember to like, pay attention to and collect
Phenomenon: when compiling CUDA version of opencv4.1, cudnn was not found when using cmake configuration, but it was actually installed
Reason: since the cudnn version installed is 8.2, the macro definition (cudnn) of cudnn version was originally recorded_ Major and cudnn_ Minor) moved from cudnn. H to cudnn_ version.h。
Resolution: not processed
It’s not known if it will affect the compilation, but camke found cudnn. So ((found/usr/local/cuda-11.1/lib64/libcudnn. So)).
When SIFT algorithm is used for matching, an error is reported during compilation:
fatal error: opencv2/nonfree/nonfree.hpp: Not having that file or directory
#include <opencv2/nonfree/nonfree.hpp>
When you go online, you basically say to download opencv nonfree:
sudo apt-get update
sudo add-apt-repository --yes ppa:xqms/opencv-nonfree
sudo apt-get update
sudo apt-get install libopencv-nonfree-dev
As a result, a new error is reported when the second instruction is run:
sudo add-apt-repository --yes ppa:xqms/opencv-nonfree
Cannot add PPA: 'ppa:~xqms/ubuntu/opencv-nonfree'.
ERROR: '~xqms' user or team does not exist.
After careful review, it is found that the opencv2. X version is still very good to install under the Ubuntu system. You only need to install it through the above instructions
opencv-3.4.0/opencv_contrib-3.4.0/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp
Put #include < opencv2/nonfree/nonfree.hpp> Change to absolute path and solve it.
Question:
##Boundary fill
import cv2
top_size,bottom_size,left_size,right_size=(50,50,50,50)
replicate=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,boderType=cv2.BORDER_REPLICATE)
reflect=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,boderType=cv2.BORDER_REFLECT)
reflect101=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,boderType=cv2.BORDER_REFLECT101)
wrap=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,boderType=cv2.BORDER_WRAP)
constant=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,boderType=cv2.BORDER_CONSTANT,value=0)
Outcome:
error Traceback (most recent call last)
<ipython-input-39-820a457b4770> in <module>
2 import cv2
3 top_size,bottom_size,left_size,right_size=(50,50,50,50)
----> 4 replicate=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,boderType=cv2.BORDER_REPLICATE)
5 reflect=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,boderType=cv2.BORDER_REFLECT)
6 reflect101=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,boderType=cv2.BORDER_REFLECT101)
error: OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function 'copyMakeBorder'
> Overload resolution failed:
> - copyMakeBorder() missing required argument 'borderType' (pos 6)
> - copyMakeBorder() missing required argument 'borderType' (pos 6)
analysis:
error: OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function 'copyMakeBorder'
> Overload resolution failed:
> - copyMakeBorder() missing required argument 'borderType' (pos 6)
> - copyMakeBorder() missing required argument 'borderType' (pos 6)
“Bordertype” spelling error!!!!
Correct code:
##Boundary fill
import cv2
top_size,bottom_size,left_size,right_size=(50,50,50,50)
replicate=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,borderType=cv2.BORDER_REPLICATE)
reflect=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,borderType=cv2.BORDER_REFLECT)
reflect101=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,borderType=cv2.BORDER_REFLECT101)
wrap=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,borderType=cv2.BORDER_WRAP)
constant=cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,borderType=cv2.BORDER_CONSTANT,value=0)
import matplotlib.pyplot as plt
plt.subplot(231),plt.imshow(img,'gray'),plt.title('ORIGINAL')
plt.subplot(232),plt.imshow(replicate,'gray'),plt.title('REPLICATE')
plt.subplot(233),plt.imshow(reflect,'gray'),plt.title('REFLECT')
plt.subplot(234),plt.imshow(reflect101,'gray'),plt.title('REFLECT101')
plt.subplot(235),plt.imshow(wrap,'gray'),plt.title('WRAP')
plt.subplot(236),plt.imshow(constant,'gray'),plt.title('CONSTANTL')
plt.show()
Output results:
Error resolution
Could not find a package configuration file provided by "moveit_core" with
any of the following names:
moveit_coreConfig.cmake
moveit_core-config.cmake
Add the installation prefix of "moveit_core" to CMAKE_PREFIX_PATH or set
"moveit_core_DIR" to a directory containing one of the above files. If
"moveit_core" provides a separate development package or SDK, be sure it
has been installed.
Reason: the cmakelists.txt file does not specify the DNN module, so the statement
find_package(OpenCV 4 REQUIRED opencv_core opencv_imgproc opencv_highgui opencv_calib3d opencv_videoio opencv_imgcodecs )
To be amended as follows:
find_package(OpenCV 4 REQUIRED)
It can be compiled.
Installing denseflow compiles with the following error./home/m/src/denseflow/src/denseflow_gpu.cpp:2:10: fatal error: opencv2/cudaarithm.hpp: No such file or directory
#include “opencv2/cudaarithm.hpp”
where the keywords are
/home/m/src/denseflow/src/denseflow_gpu.cpp
cudaarithm.hpp
The solution is as follows.
1、Find the path where cudaarithm.hpp is located
sudo find/-name "cudaarithm.hpp"
A path similar to:
/home/m/src/opencv_contrib/modules/cudaarithm/include/opencv2/cudaarithm.hpp
/home/m/include/opencv4/opencv2/cudaarithm.hpp
............
..............
Then fill the absolute path into denseflow_ Gpu.cpp replaces relative path
#You have to fill in the absolute paths, and our paths may be different, you have to follow your own
sudo vim /home/m/src/denseflow/src/denseflow_gpu.cpp
Before replacing
#include “opencv2/cudaarithm.hpp”
After replacement
#include “/home/m/include/opencv4/opencv2/cudaarithm.hpp”
Compile again, the problem is solved.
1-35013;- VS2019-36733;- OpenCvSharpExterior-283044;-
2’38468;’21547;’ 24405s;
D:\VS2019\opencvsharp-4.4.0.20200916\opencv files\opencv440 win x64\include\3rdparty\ippicv\ippicv win\icv\include
D:\VS2019\opencvsharp-4.4.0.20200916\\\opencv files\opencv440 wine x64\include
3-38745;- 24577;- 24211;- 38468;-
liblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibliblibzlibd.lib
opencv aruco440d.lib
opencv bgsegm440d.lib
opencv bioinspired440d.lib
opencv calib3d440d.lib
The opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening of the opening lib
opencv fuzzy440d.lib
opencv hfs440d.lib
opencv highgui440d.lib
opencv imgcodecs440d.lib
opencv imgproc440d.lib
open the line to descridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescridescriopen open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open up photo4440d.libopen open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open open 40d.lib
opencv quality 440d.lib
opencv reg440d.lib
opencv rgbd440d.lib
opencv saliency440d.lib
The opening of the opening of the structural opening of the superstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstsuperstremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremaremarema
opencv ts440d.lib
opencv video440d.lib
opencv videoio440d.lib
opencv videostab440d.lib
opencv xfeatures2d440d.lib
opencv ximgproc440d.lib
opencv xobjdetect440d.lib
opencv xphoto440d.lib
OpenCV 357933387454524577;24211s;
img = cv2.resize(img, (512, 1024))
cv2.error: OpenCV(4.2.0) /io/opencv/modules/imgproc/src/resize. cpp:4045 : error: (-215:Assertion failed) ! ssize.empty() in function ‘resize’
The code can run normally in win10, but the above error is reported in Linux. My analysis is due to the different address reading formats between win10 and Linux.
img = cv2.imread(item['path'])
#item['path']:'./data/TuSimple/LaneDetection\clips/0313-2/42120/20.jpg'
There is a ‘\’ in the address of item [‘path ‘], which results in an error in Linux operation
so change the’ \ ‘in the address of item [‘path’] to ‘/’
item['path']=item['path'].replace('\\', '/')#Add this code
img = cv2.imread(item['path'])
This problem occurred when I ran C + + opencv code. I realized that the mask format I entered was incorrect, not the. PNG or. JPG problem I wrote. The source of the problem may be that CV2. Imread() is loading an empty matrix. Instead of delving into this problem, I will check your input image and mask name and format again. I think this error is a sign that the image cannot be loaded correctly. You need to check your code imread read read problem, whether the file name is correct and whether there is a problem with the file input path. Finally, I changed the way the file path was read
My modification: change the input path in the program parameters to:
The above is my solution to this problem, the correct operation of the modified code.
Solve the problem of solvepnp (outdim, indim, cameramatrix, distcoeff, RVEC, tvec); There is an unhandled exception at 0x00007ffbc3844b89 (in biaoding.exe): Microsoft C + + exception: CV:: exception, in the memory location of 0x000000571351b2d0
Mapping 3D point cloud to 2D image, using OpenCV solvepnp, running error
OpenCV(4.5.1) Error: Assertion failed (( (npoints >= 4) || (npoints == 3 && amp; flags == SOLVEPNP_ ITERATIVE && amp; useExtrinsicGuess) || (npoints >= 3 && amp; flags == SOLVEPNP_ SQPNP) ) && amp; npoints == std::max(ipoints.checkVector(2, CV_ 32F), ipoints.checkVector(2, CV_ 64F))) in cv::solvePnPGeneric, file C:\build\master_ winpack-build-win64-vc15\opencv\modules\calib3d\src\solvepnp.cpp, line 802
The error is as follows:
The input coordinates of 3D point cloud and 2D pixel are:
Conversion type:
After the conversion, the output of outdim and indim is changed, and it is no longer a 6 * 3 matrix, so an error will be reported
So the error is because the matrix dimensions in solvepnp are inconsistent. The solution is to use push again in the most stupid way_ Back redefines outdim and indim, instead of using for loop to define outdim and indim, just in case cameramatrix is also redefined
Finally, the rotation translation matrix from radar to camera and the result map of point cloud mapping to image are obtained
div>