• ubuntu 22 cross compile OpenCV 4.8 for RK3588


    1 down load opencv 4.8

    https://opencv.org/releases/

    2 mkdir build && cd build

    mkdir build
    cd build/
    
    • 1
    • 2

    在这里插入图片描述

    3 cmake …

    sudo cmake .. -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=../install -D ENABLE_FAST_MATH=1 -D WITH_OPENCL=ON -D WITH_IPP=OFF -D ITH_GTK=ON -D WITH_GTK3=ON  -D BUILD_SHARED_LIBS=OFF -D CMAKE_C_COMPILER=/home/jeffrey/360/host/bin/aarch64-buildroot-linux-gnu-gcc -D CMAKE_CXX_COMPILER=/home/jeffrey/360/host/bin/aarch64-buildroot-linux-gnu-g++
    
    • 1

    在这里插入图片描述

    4 make -j12

    make -j12
    
    • 1

    ---------------------------------------remap ocl -------------------------------------------------------------

    1 main

    #include 
    #include 
    #include 
    #include 
    #include 
    
    using namespace cv;
    void perspective_to_maps(cv::Matx33d &perspective_mat, cv::Size img_size, cv::Mat &map1, cv::Mat &map2)
    {
        cv::Mat inv_perspective(perspective_mat.inv());
        inv_perspective.convertTo(inv_perspective, CV_32FC1);
    
        cv::Mat xy(img_size, CV_32FC2);
        float *pxy = (float *)xy.data;
        for (int y = 0; y < img_size.height; y++)
            for (int x = 0; x < img_size.width; x++)
            {
                *pxy++ = x;
                *pxy++ = y;
            }
        // perspective transformation of the points
        cv::Mat xy_transformed;
        cv::perspectiveTransform(xy, xy_transformed, inv_perspective);
        assert(xy_transformed.channels() == 2);
        cv::Mat maps[2];
        cv::split(xy_transformed, maps);
        cv::convertMaps(maps[0], maps[1], map1, map2, CV_32F);
    }
    cv::Mat mapx,mapy,dst1,dst2;
    cv::Matx33d homog(-1.104333310637919, -1.02803450593307, 4.132532927151,
    -0.08141394964341982, -1.35103411932037, 4.2699610224884,
    -0.0003145704784753452, -0.002810559414638452, 1);
    int main(int argc, char **argv) 
    {
         
        cv::Size size_map(6, 6);
        perspective_to_maps(homog,size_map,mapx,mapy);    
      
        cv::Mat src = Mat::zeros(size_map,CV_8UC1);  // cv::Mat src= cv::imread("../image/back.png",cv::IMREAD_GRAYSCALE);
        for(int i = 0; i < src.cols;i++) 
                for (int j=0; j < src.cols; j++) 
                    src.at<u_char>(i, j) = (i + j)*20;
    
        cv::resize(src, src, size_map, 0, 0, cv::INTER_NEAREST);
        cv::UMat usrc;
        cv::UMat udst1;
        src.copyTo(usrc);
        // 
        cv::UMat usrc1;
        cv::UMat usrc2;
        cv::UMat usrc3;
        cv::UMat usrc4;
        
        src.copyTo(usrc1);
        src.copyTo(usrc2);
        src.copyTo(usrc3);
        src.copyTo(usrc4);
        int num=100;
        char *p_a[num];
        for(int i=0;i<num;i++)
        {
            char *p = (char*) malloc((1000*1000*sizeof(char)));
            p_a[i]=p;
            if (p != NULL)
            {
                printf("malloc successfully 5*1000*1000*1000\n");
            }
            else
            {
                printf("malloc failed\n");
            }
        }
    
        cv::remap(usrc, udst1, mapx, mapy, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar(0));
        cv::remap(usrc1, udst1, mapx, mapy, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar(0));
        cv::remap(usrc2, udst1, mapx, mapy, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar(0));
        cv::remap(usrc3, udst1, mapx, mapy, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar(0));
        cv::remap(usrc4, udst1, mapx, mapy, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar(0));
        while(1)
        {;}
    
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83

    2 log

    Status -11: CL_BUILD_PROGRAM_FAILURE
    -D INTER_LINEAR -D BORDER_CONSTANT -D T=uchar -D rowsPerWI=1 -D WT=float -D convertToT=convert_uchar_sat_rte -D convertToWT=convert_float -D convertToWT2=convert_float2 -D WT2=float2 -D T=uchar -D T1=uchar -D cn=1 -D ST=uchar -D depth=0
    :175:9: error: expected member name or ‘;’ after declaration specifiers
    int32_t depth; /**< The image depth. */
    ^
    :14:15: note: expanded from here
    #define depth 0
    ^

    :175:8: error: expected ‘;’ at end of declaration list
    int32_t depth; /**< The image depth. */
    ^

    error: Compiler frontend failed (error code 62)

    3 how to resolve

    change depth in line 1362 to m_depth

    在这里插入图片描述

  • 相关阅读:
    一起学docker系列之四docker的常用命令--系统操作docker命令及镜像命令
    【Python百日进阶-数据分析】Day117 - Plotly 是免费的吗?
    js构造函数
    pyspark.sql.dataframe.DataFrame 怎么转pandas DataFrame
    三季报开启消费电子增长新纪元?看蓝思科技如何落子
    Vue组件理解及非单文件组件
    浅浅的整理一下机器学习简单资料
    JSON数据格式
    存u盘里的视频没删除找不到了怎么办?别急,这几招来帮您
    敏捷开发-任务拆解、工作量评估和任务指派
  • 原文地址:https://blog.csdn.net/qq_36784503/article/details/134293204