zoukankan      html  css  js  c++  java
  • 操作MAT矩阵(转)

        t = (double)getTickCount();
        Mat img1(1000, 1000, CV_32F);
        
        for (int i=0; i<1000; i++)
        {
            for (int j=0; j<1000; j++)
            {
                img1.at<float>(i,j) = 3.2f;
            }
        }
        t = (double)getTickCount() - t;
        printf("in %gms
    ", t*1000/getTickFrequency());
        //***************************************************************
        t = (double)getTickCount();
        Mat img2(1000, 1000, CV_32F);
    
        for (int i=0; i<1000; i++)
        {
            for (int j=0; j<1000; j++)
            {
                img2.ptr<float>(i)[j] = 3.2f;
            }
        }
        t = (double)getTickCount() - t;
        printf("in %gms
    ", t*1000/getTickFrequency());
        //***************************************************************
        t = (double)getTickCount();
        Mat img3(1000, 1000, CV_32F);
        float* pData = (float*)img3.data;
    
        for (int i=0; i<1000; i++)
        {
            for (int j=0; j<1000; j++)
            {
                *(pData) = 3.2f;
                pData++;
            }
        }
        t = (double)getTickCount() - t;
        printf("in %gms
    ", t*1000/getTickFrequency());
        //***************************************************************
        t = (double)getTickCount();
        Mat img4(1000, 1000, CV_32F);
    
        for (int i=0; i<1000; i++)
        {
            for (int j=0; j<1000; j++)
            {
                ((float*)img3.data)[i*1000+j] = 3.2f;
            }
        }
        t = (double)getTickCount() - t;
        printf("in %gms
    ", t*1000/getTickFrequency());

    http://blog.csdn.net/yang_xian521/article/details/7161335

  • 相关阅读:
    Python文件相关的操作
    Python运算符
    字符串方法
    Python列表的增删改查和元祖
    压测
    jmeter相关使用
    charles的使用
    接口测试
    编程珠玑之关键字(1)--《c语言深度剖析》整理(转)
    循环单链表操作(转)
  • 原文地址:https://www.cnblogs.com/chchche/p/3185249.html
Copyright © 2011-2022 走看看