• <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>
            是塵封已久的記憶再次融化 是堆積心底的烈火再次燃燒 是直覺讓我來到這久違的大地 是信念讓我開始了新的征途 在硝煙中我得到了成長 在傷痛中我學會了堅強 在沉默中我明白了等待 在孤獨中我體味了感傷 并不是我不懂得眼淚 并不是我只知道使命 在內心深處我同你一樣火熱 在我的眼中也有著多情的淚光 也許我的生命如落葉般短暫 也許我只是歲月長河中的一個過客 但我對自己所做的一切無怨無悔 因為我品嘗到了那最后一刻的淚光
            隨筆-6  評論-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 閱讀(1795) 評論(1)  編輯 收藏 引用

            評論:
            # re: 用cuda操作IplImage中的數據 2010-08-23 13:46 | STICKGY
            您好,我是OPENCV以及CUDA的初學者,我現在要完成一個任務,就是把OPENCV和CUDA配置到一起,把它倆結合起來編程,雖然我還不是很懂,但是應該就是得到類似于您文章中的效果吧!但是把不清楚應該怎樣進行,甚至創建什么項目、在哪種文件(.cpp or .cu)中編程,希望您能給予適當的指教,謝謝!  回復  更多評論
              
            亚洲综合久久久| 99久久精品国产一区二区三区| 久久国产视屏| 久久久久人妻一区精品| 久久天天躁狠狠躁夜夜96流白浆| 久久狠狠高潮亚洲精品| 久久se精品一区精品二区国产| 亚洲欧洲日产国码无码久久99| 99国产精品久久久久久久成人热| 免费精品久久久久久中文字幕| 九九久久自然熟的香蕉图片| 久久中文字幕无码专区| 久久伊人精品青青草原高清| 日本国产精品久久| 久久99精品国产麻豆宅宅 | 久久久久久毛片免费播放| 精品久久综合1区2区3区激情| 久久Av无码精品人妻系列| 亚洲AⅤ优女AV综合久久久| 青青草原综合久久大伊人精品| 亚洲精品蜜桃久久久久久| 久久青青草原精品国产不卡| 久久九九青青国产精品| 久久ww精品w免费人成| 久久久老熟女一区二区三区| 久久精品国产亚洲av麻豆蜜芽 | 久久av无码专区亚洲av桃花岛| 超级97碰碰碰碰久久久久最新| 久久综合久久久| 久久超碰97人人做人人爱| 成人久久综合网| 亚洲AV无码久久精品蜜桃| 久久强奷乱码老熟女网站| 久久久久久久精品妇女99| 国产精品久久新婚兰兰| 成人久久免费网站| 精品久久亚洲中文无码| 久久亚洲精品人成综合网| 99久久人妻无码精品系列蜜桃| 久久久久亚洲av无码专区导航| 无码国内精品久久人妻蜜桃|