1. 程式人生 > >SiftGPU一些細節整理

SiftGPU一些細節整理

聯合opencv開發

static int  IsSimpleGlFormat(unsigned int gl_format, unsigned int gl_type)
{
	//the formats there is a cpu code to conver rgb and downsample
	return (gl_format == GL_LUMINANCE || gl_format == GL_LUMINANCE_ALPHA ||
		gl_format == GL_RGB || gl_format == GL_RGBA ||
		gl_format == GL_BGR || gl_format == GL_BGRA) &&
		(gl_type == GL_UNSIGNED_BYTE || gl_type == GL_FLOAT || gl_type == GL_UNSIGNED_SHORT);
}

GL_LUMINANCE - 亮度

GL_LUMINANCE_ALPHA 亮度+透明度

對於影象的長和寬,灰度和彩色不影響,直接用哪個都行

cv::Mat img1 = cv::imread("../../data/img3.ppm", 1);
cv::Mat grayImg1;
cv::cvtColor(img1, grayImg1, CV_BGR2GRAY);
int width1 = grayImg1.cols;
int height1 = grayImg1.rows;
sift->RunSIFT(width1, height1, img1.data, GL_BGR, GL_UNSIGNED_BYTE);

假如輸入影象是灰度圖怎麼辦,接下來應該怎麼處理?

sift->RunSIFT(width1, height1, grayImg1.data, GL_LUMINANCE, GL_UNSIGNED_BYTE)