• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            是塵封已久的記憶再次融化 是堆積心底的烈火再次燃燒 是直覺(jué)讓我來(lái)到這久違的大地 是信念讓我開(kāi)始了新的征途 在硝煙中我得到了成長(zhǎng) 在傷痛中我學(xué)會(huì)了堅(jiān)強(qiáng) 在沉默中我明白了等待 在孤獨(dú)中我體味了感傷 并不是我不懂得眼淚 并不是我只知道使命 在內(nèi)心深處我同你一樣火熱 在我的眼中也有著多情的淚光 也許我的生命如落葉般短暫 也許我只是歲月長(zhǎng)河中的一個(gè)過(guò)客 但我對(duì)自己所做的一切無(wú)怨無(wú)悔 因?yàn)槲移穱L到了那最后一刻的淚光
            隨筆-6  評(píng)論-24  文章-8  trackbacks-0
             1#include <cutil_inline.h>
             2#include <cv.h>
             3#include <cstdio>
             4#include <iostream>
             5#include <cutil.h>
             6#include <ctime>
             7#include <cstdlib>
             8#include <highgui.h>
             9#include <windows.h>
            10
            11#pragma comment(lib, "cuda.lib")
            12#pragma comment(lib, "cudart.lib")
            13#pragma comment(lib, "cutil32.lib")
            14#pragma comment(lib, "cv.lib")
            15#pragma comment(lib, "cxcore.lib")
            16#pragma comment(lib, "highgui.lib")
            17
            18using namespace std;
            19
            20__global__ void mainKernel(unsigned char *d_data, int widthStep, int width, int height)
            21{
            22    unsigned int x = blockIdx.x*blockDim.x+threadIdx.x;
            23    unsigned int y = blockIdx.y*blockDim.y+threadIdx.y;
            24    if( x>0 && x < width && y>0 && y < height )
            25    {                  
            26        d_data[y*widthStep+x*3+0^= ( ((x&0x0F)==0^ ((y&0x0F)==0)  ) *255;
            27        d_data[y*widthStep+x*3+1^= ( ((x&0x0F)==0^ ((y&0x0F)==0)  ) *255;
            28        d_data[y*widthStep+x*3+2^= ( ((x&0x0F)==0^ ((y&0x0F)==0)  ) *255;
            29    }

            30}

            31
            32int main()
            33{
            34    IplImage* src = cvLoadImage("IMG_03.JPG");
            35
            36    int widthStep = src->widthStep;
            37    int width   = src->width;
            38    int height  = src->height;
            39
            40    printf("before widthStep = %d\n", widthStep);
            41    if( widthStep%4 != 0)
            42    {
            43        widthStep = (1+widthStep/4)*4;
            44    }

            45    printf("after widthStep = %d\n", widthStep);
            46
            47    unsigned char* d_img_data;
            48    CUDA_SAFE_CALL(cudaMalloc((void**)&d_img_data, widthStep*height));
            49    CUDA_SAFE_CALL(cudaMemcpy(d_img_data, src->imageData, widthStep*height, cudaMemcpyHostToDevice));
            50
            51    dim3 dimBlock(16161);
            52    dim3 dimGrid( (width+dimBlock.x-1)/dimBlock.x, (height+dimBlock.y-1)/dimBlock.y );
            53    mainKernel<<<dimGrid, dimBlock, 0>>>(d_img_data, widthStep, width, height);
            54    CUDA_SAFE_CALL(cudaThreadSynchronize());
            55
            56    CUDA_SAFE_CALL( cudaMemcpy( src->imageData, d_img_data, widthStep*height, cudaMemcpyDeviceToHost) );
            57    
            58    cvNamedWindow("test",CV_WINDOW_AUTOSIZE);
            59    cvShowImage("test",src);
            60    cvWaitKey(0);
            61    cvDestroyAllWindows();
            62
            63    cvReleaseImage(&src);
            64    CUDA_SAFE_CALL(cudaFree(d_img_data));
            65    return 0;
            66}
            posted on 2009-12-28 10:58 noBugnoGain 閱讀(1802) 評(píng)論(1)  編輯 收藏 引用

            評(píng)論:
            # re: 用cuda操作IplImage中的數(shù)據(jù) 2010-08-23 13:46 | STICKGY
            您好,我是OPENCV以及CUDA的初學(xué)者,我現(xiàn)在要完成一個(gè)任務(wù),就是把OPENCV和CUDA配置到一起,把它倆結(jié)合起來(lái)編程,雖然我還不是很懂,但是應(yīng)該就是得到類似于您文章中的效果吧!但是把不清楚應(yīng)該怎樣進(jìn)行,甚至創(chuàng)建什么項(xiàng)目、在哪種文件(.cpp or .cu)中編程,希望您能給予適當(dāng)?shù)闹附蹋x謝!  回復(fù)  更多評(píng)論
              

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            人妻无码久久一区二区三区免费| 潮喷大喷水系列无码久久精品| 国内精品久久久久影院一蜜桃| 2021国产精品久久精品| 久久毛片免费看一区二区三区| 国产亚洲精午夜久久久久久| 国产精品欧美久久久久无广告 | 久久综合九色综合久99| 国产一区二区三区久久精品| 国产一区二区三区久久| 久久久久中文字幕| 久久激情亚洲精品无码?V| 合区精品久久久中文字幕一区| 日本欧美国产精品第一页久久| 99精品国产免费久久久久久下载| 久久中文字幕人妻丝袜| 欧美亚洲色综久久精品国产| 国产精品久久国产精麻豆99网站| 久久最新精品国产| 久久久久亚洲AV成人网| 久久无码中文字幕东京热| 少妇内射兰兰久久| 嫩草影院久久99| 欧美一级久久久久久久大| 一本色道久久综合亚洲精品| 久久国产高清字幕中文| 美女久久久久久| 久久久女人与动物群交毛片| segui久久国产精品| 久久综合久久综合亚洲| 久久久久人妻一区精品性色av| 国产精品99久久精品| 香蕉久久永久视频| 996久久国产精品线观看| 亚洲国产香蕉人人爽成AV片久久| 伊人久久大香线蕉av不卡| 色综合久久综精品| 97精品伊人久久久大香线蕉| 国内精品久久久久影院网站| 亚洲va中文字幕无码久久| 久久久久女教师免费一区|