Make writing a habit together! This is my first day to participate in the “Gold Digging Day New Plan Β· April More text challenge”, click to see the details of the activity.

  • πŸŽ‰ statement: as one of the bloggers in AI field, ❀️ lives up to your time and your ❀️
    • 🍊 # Column: Image processing

    • 🍊 thanks to every reader for your support and recognition

    • 🍊 πŸ‘‹ Follow me πŸ‘‹, join us to Get more interesting AI, charge πŸš€ πŸ‘‹


    πŸ’™openCV download and install


    ❀️ Basic Environment

    • Operating system: Ubuntu 18.04.5
    • Programming tool: Bash shell
    • VScode
    • Basic GCC, G++ installation

    ❀️ Download a preferred version

    • Github.com/opencv/open…

    ❀️ Minimal [brainless] installation

    
    Unzip to the server directoryUnzip opencv - 4.5.3cdOpencv 4.5.3 /# Start the installation tour
    
    mkdir build
    cd build/
    
    /usr/local = /usr/local
    cmake ..
    make -j16
    make install
    
    /usr/local = /usr/local = /usr/local
    
    make install DESTDIR=/home/Moli/usr/local 
    
    Copy the code

    πŸ’™openCV reads and saves images [minimalist example]


    Program contains only | example. CPP and CMakeLists. TXT

    ❀ ️ example. CPP

    #include "opencv2/core.hpp"
    #include "opencv2/imgproc.hpp"
    #include "opencv2/highgui.hpp"
    #include "opencv2/videoio.hpp"
    #include <iostream>
    
    using namespace cv;
    using namespace std;
    
    int main(a)
    {
        cout << "Built with OpenCV " << CV_VERSION << endl;
        Mat src = cv::imread(".. /conda.png");
        // cv::imshow("src", src);
        // waitKey(0);
        // Image zoom
        int width{256}, height{256};
        cv::resize(src, src, cv::Size(width, height));
    
        cv::imwrite("256src.png", src);
        return 0;
    }
    
    Copy the code

    ❀ ️ CMakeLists. TXT

    OpenCV_DIR = openCV build

    # cmake needs this line
    cmake_minimum_required(VERSION 3.1)
    
    # Define project name
    project(Richard _project first_ ink)
    
    # Find OpenCV, you may need to set OpenCV_DIR variable
    # to the absolute path to the directory containing OpenCVConfig.cmake file
    # via the command line or GUI
    
    set(OpenCV_DIR /home/咨理/project/project21Next/vscodeFirst/opencv4.53./build)
    find_package(OpenCV REQUIRED)
    
    # If the package has been found, several variables will
    # be set, you can find the full list with descriptions
    # in the OpenCVConfig.cmake file.
    # Print some message showing some of them
    message(STATUS "OpenCV library status:")
    message(STATUS " config: ${OpenCV_DIR}")
    message(STATUS " version: ${OpenCV_VERSION}")
    message(STATUS " libraries: ${OpenCV_LIBS}")
    message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
    
    # Declare the executable target built from your sources
    add_executable(first example.cpp)
    
    # Link your application with OpenCV libraries
    target_link_libraries(first PRIVATE ${OpenCV_LIBS})
    
    Copy the code

    πŸ’™ Compile and run in Linux


    The command is

    mkdir build
    
    cd  build/
    
    cmake ..
    make
    
    # generated executable file can be run first |
    
    ./first 
    
    Copy the code

    View the resulting zoom image.

    Profile of the blogger: Master of Software Engineering, graduated, soon 10W readers and fans

    • 🍊 Computer vision: some knowledge in superresolution reconstruction, image restoration, object detection, style transfer and other fields
    • 🍊 AI engineering: Ncnn, MNN, TensorRT are learning
    • 🍊 C++, Python, Java

    Please pay attention to moneo-ai and its namesake public number Moneo-AI

    On the way to learn lessons, let mohli AI accompany you to enjoy more interesting AI