锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
#define N 6
HANDLE hSuspend[N], hResume[N];
HANDLE hSuspend_one;
HANDLE hResume_one;
struct info
{
CRITICAL_SECTION ProtectSection;
int id;
int frames;
};

unsigned long __stdcall testFun(void *pContext)
{
info* pInfo = (info*)pContext;
while(1)
{
EnterCriticalSection(&pInfo->ProtectSection);
pInfo->frames++;
//printf("run sub Thread video %d frames %d\n", pInfo->id, pInfo->frames);
// DWORD rtn = WaitForSingleObject(hSuspend[pInfo->id], INFINITE);
DWORD rtn = WaitForSingleObject(hSuspend_one, INFINITE);
if (WAIT_OBJECT_0 == rtn)
{// 鑷繁鏆傚仠鑷繁
// printf("stop sub Thread video %d frames %d\n", pInfo->id, pInfo->frames);
WaitForSingleObject(hResume[pInfo->id], INFINITE);
//WaitForSingleObject(hResume_one, INFINITE);
}
LeaveCriticalSection(&pInfo->ProtectSection);
}
return 0;
}

int main()
{
DWORD thid;
HANDLE hand[N];
int mainframes = 0;
info myInfo[N];
hSuspend_one = CreateEvent(NULL, TRUE, FALSE, NULL);
for(int i = 0; i < N; i++)
{
hSuspend[i] = CreateEvent(NULL, TRUE, FALSE, NULL);
hResume[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
myInfo[i].id = i;
myInfo[i].frames = 0;
InitializeCriticalSection(&myInfo[i].ProtectSection);
}
for(int i = 0; i < N; i++)
{
hand[i] = CreateThread( NULL, NULL, testFun, &myInfo[i], CREATE_SUSPENDED, &thid);
}
for(int i = 0; i < N; i++)
{
ResumeThread(hand[i]);
}
while(1)
{
printf("main thread frames %d\n", ++mainframes);
/*for(int i = 0; i < N; i++)
{
SetEvent(hSuspend[i]);
}*/
SetEvent(hSuspend_one);
Sleep(5);
for(int i = 0; i < N; i++)
{
printf("main thread video %d frames %d\n",myInfo[i].id,myInfo[i].frames);
}
printf("\n");
for(int i = 0; i < N; i++)
{
SetEvent(hResume[i]);
}
}
for(int i = 0; i < N; i++)
{
WaitForSingleObject(hand[i], INFINITE);
DeleteCriticalSection( &myInfo[i].ProtectSection);
CloseHandle(hand[i]);
CloseHandle(hResume[i]);
CloseHandle(hSuspend[i]);
}
CloseHandle(hSuspend_one);
return 0;
}
#include <cutil_inline.h>
#include <cv.h>
#include <cstdio>
#include <iostream>
#include <cutil.h>
#include <ctime>
#include <cstdlib>
#include <highgui.h>
#include <windows.h>
#pragma comment(lib, "cuda.lib")
#pragma comment(lib, "cudart.lib")
#pragma comment(lib, "cutil32.lib")
#pragma comment(lib, "cv.lib")
#pragma comment(lib, "cxcore.lib")
#pragma comment(lib, "highgui.lib")
using namespace std;
__global__ void mainKernel(unsigned char *d_data, int widthStep, int width, int height)

{
unsigned int x = blockIdx.x*blockDim.x+threadIdx.x;
unsigned int y = blockIdx.y*blockDim.y+threadIdx.y;
if( x>0 && x < width && y>0 && y < height )
{
d_data[y*widthStep+x*3+0] ^= ( ((x&0x0F)==0) ^ ((y&0x0F)==0) ) *255;
d_data[y*widthStep+x*3+1] ^= ( ((x&0x0F)==0) ^ ((y&0x0F)==0) ) *255;
d_data[y*widthStep+x*3+2] ^= ( ((x&0x0F)==0) ^ ((y&0x0F)==0) ) *255;
}
}
int main()

{
IplImage* src = cvLoadImage("IMG_03.JPG");
int widthStep = src->widthStep;
int width = src->width;
int height = src->height;
printf("before widthStep = %d\n", widthStep);
if( widthStep%4 != 0)
{
widthStep = (1+widthStep/4)*4;
}
printf("after widthStep = %d\n", widthStep);
unsigned char* d_img_data;
CUDA_SAFE_CALL(cudaMalloc((void**)&d_img_data, widthStep*height));
CUDA_SAFE_CALL(cudaMemcpy(d_img_data, src->imageData, widthStep*height, cudaMemcpyHostToDevice));
dim3 dimBlock(16, 16, 1);
dim3 dimGrid( (width+dimBlock.x-1)/dimBlock.x, (height+dimBlock.y-1)/dimBlock.y );
mainKernel<<<dimGrid, dimBlock, 0>>>(d_img_data, widthStep, width, height);
CUDA_SAFE_CALL(cudaThreadSynchronize());
CUDA_SAFE_CALL( cudaMemcpy( src->imageData, d_img_data, widthStep*height, cudaMemcpyDeviceToHost) );
cvNamedWindow("test",CV_WINDOW_AUTOSIZE);
cvShowImage("test",src);
cvWaitKey(0);
cvDestroyAllWindows();
cvReleaseImage(&src);
CUDA_SAFE_CALL(cudaFree(d_img_data));
return 0;
}
GSS and DoG scale space structures
GSS:Gaussian scale space錛堥珮鏂昂搴︾┖闂達級
DoG: Difference of Gaussians錛堥珮鏂樊鍒嗭級
octave index:灞傜儲寮?br>scale index:灝哄害绱㈠紩
寤虹珛鍥懼儚鐨勯珮鏂昂搴︾┖闂村叾瀹炲氨鏄敤楂樻柉鏍稿鍥懼儚榪涜鍗風Н錛屼竴灞備竴灞傜殑騫蟲粦鍥懼儚錛屼竴灞傚張鍒嗚嫢騫蹭釜scale. 姣忎釜scale鐨勯噰鏍鋒闀夸負錛?br>![]()
寤虹珛濂介珮鏂昂搴︾┖闂村悗錛屽啀閫氳繃寤虹珛楂樻柉宸垎灝哄害絀洪棿瀵繪壘鍥懼儚鐨勫眬閮ㄦ瀬鍊箋傞珮鏂樊鍒嗗昂搴︾┖闂村緩绔嬪緢綆鍗曪紝瀵歸珮鏂昂搴︾┖闂寸殑榪炵畫鍥懼儚鐩稿噺灝卞彲浠ヤ簡銆傚叿浣撳叕寮忓涓?
.
鏋佸肩殑紜畾濡傚浘錛?br> 
鍦ㄥ浘鍍忛珮鏂樊鍒嗗昂搴︾┖闂村唴褰撳墠灝哄害鍜屽叾鐩擱偦涓や釜灝哄害3*3鐨勫尯鍩熷唴錛屾爣璁扮殑X鍜屽叾浠?6涓儚绱犳瘮杈冿紝濡傛灉X鐨勭伆搴﹀ぇ浜庢垨鑰呭皬浜庡叾浠?6涓儚绱犮傞偅涔堣繖涓猉灝辨槸涓瀬鍊箋?br> 寤虹珛楂樻柉灝哄害絀洪棿鏈変簺緇嗚妭鐨勯棶棰橈紝鍏蜂綋鍙互鐪婦avid G.low鐨勮鏂囥?/strong>