1. Implement virtual machine and host file transfer
Use xftp
sudo apt-get install openssh-serve
At the same time, xshell can be used to achieve remote connection under the LAN. (Use the command ifconfig to check the virtual machine IP address. If the command cannot be found, install net-tools command: sudo apt-get install net-tools)
2. Implement text copy and paste function between virtual machine and host machine
Install open-vm-tools-desktop, shut down ubantu and the virtual machine after success, and then restart.
sudo apt-get install open-vm-tools-desktop
3.Ubuntu20 install opencv
①Install from the Ubuntu source repository (avoiding the torture of libjasper-dev!!!)
OpenCV is available in Ubuntu 20.04 software repositories. To install it, run:
sudo apt update
sudo apt install libopencv-dev python3-opencv
The above command will install all necessary packages to run OpenCV:
Verify the installation by importing cv2
the module and printing the OpenCV version:
python3 -c "import cv2; print(cv2.__version__)"
For example: output:
4.2.0
②Source code installation
1. Install the tool package and all dependent packages:
sudo apt install build-essential cmake git pkg-config libgtk-3-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
gfortran openexr libatlas-base-dev python3-dev python3-numpy \
libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev \
libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
2. Clone all OpenCV and OpenCV contrib sources:
(Optional) Create a folder yourself if necessary
mkdir opencv
Go into the folder you created
cd opencv
clone
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
If you want to install an older version, cd to the opencv
and opencv_contrib
directory and run git checkout <opencv-version>
.
After the download is completed, a temporary build directory opencv will be created. Switch to this directory:
cd ./opencv
mkdir -p build
cd build
Configure the OpenCV build using CMake commands:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_GENERATE_PKGCONFIG=YES \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
The output is as follows:
- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/opencv_build/opencv/build
04. Start the compilation process:
make -j2
Modify the value according to your processor -f
. If you don't know your processor core number, you can enter it nproc
to find out.
05.Install OpenCV:
sudo make install
06. Verify the installation result, enter the following command, then you will see the OpenCV version:
C++ bindings:
pkg-config --modversion opencv4
Output:
4.3.0
Python bindings:
python3 -c "import cv2; print(cv2.__version__)"
Output:
4.3.0-dev