当前位置: 首页>>代码示例>>C++>>正文


C++ MyImage::setHeight方法代码示例

本文整理汇总了C++中MyImage::setHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ MyImage::setHeight方法的具体用法?C++ MyImage::setHeight怎么用?C++ MyImage::setHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyImage的用法示例。


在下文中一共展示了MyImage::setHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

/** @function main */
int main( int argc, char** argv )
{
    //300 350
    
    double probability = 0.6;

    std::vector<string> sourceVector = saveFileName(argv[1]);
    std::vector<string> searchVector = saveFileName(argv[2]);

    
    double matched = 0;
    
    for(std::vector<string>::iterator sourceIterator = sourceVector.begin(); sourceIterator != sourceVector.end(); sourceIterator++ ){
        for(std::vector<string>::iterator searchIterator = searchVector.begin(); searchIterator != searchVector.end(); searchIterator++ ){
            if (*sourceIterator == *searchIterator) {
                matched++;
                break;
            }
            
            
        }
    }

    probability *= (matched / sourceVector.size());
    
    
    
    MyImage *image = new MyImage();
    image->setWidth(352);
    image->setHeight(288);
    image->setImagePath(argv[1]);

    if(!image->ReadImage()){
        std::cout << "Error reading MyImage" << std::endl;
    }

    printf("%s", argv[1]);
    
    
   FILE *f = fopen(argv[1], "rb");
    if (!f) {
        printf("error\n");
        exit(1);
    }
    unsigned char pixels[352 * 288 * 3];
    fread(pixels, sizeof(unsigned char), 352*288 * 3, f);
    fclose(f);
    cv::Mat object(Size(352, 288), CV_8UC3, pixels);
    
    namedWindow("image", CV_WINDOW_AUTOSIZE);
    imshow("image", object);
    
    if( !object.data )
    {
        std::cout<< "Error reading object " << std::endl;
        return -1;
    }
    
    cv::Mat tmp, alpha;
    threshold(object, object, 255, 0, THRESH_TOZERO_INV);

    cv::Rect myROI(100, 100, 150, 150);
    
    
    int minHessian = 1000;
    
    cv::SurfFeatureDetector detector( minHessian );
    std::vector<cv::KeyPoint> kp_object;
    detector.upright = false;
    detector.detect( object, kp_object );
    
    cv::SurfDescriptorExtractor extractor;
    cv::Mat des_object;
    
    extractor.compute( object, kp_object, des_object );
    
    cv::FlannBasedMatcher matcher;
    
    
    cv::namedWindow("Good Matches");
    
    std::vector<cv::Point2f> obj_corners(4);
    
    //Get the corners from the object
    obj_corners[0] = cvPoint(0,0);
    obj_corners[1] = cvPoint( object.cols, 0 );
    obj_corners[2] = cvPoint( object.cols, object.rows );
    obj_corners[3] = cvPoint( 0, object.rows );
    
    char key = 'a';
    int framecount = 0;
    while (key != 27)
    {
       
        
        if (framecount < 5)
        {
            framecount++;
            continue;
//.........这里部分代码省略.........
开发者ID:ralfcheung,项目名称:OpenCV-Test,代码行数:101,代码来源:main.cpp

示例2: WinMain

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;

	int w, h;
	int quant = 0, coEff = 0;

	if(SQUARE == 1)
	{
		w = WIDTH;
		h = HEIGHT;
	}
	else if(RECTANGULAR == 1)
	{
		w = WIDTH;
		h = HEIGHT;
	}

	char ImagePath[_MAX_PATH];
	sscanf(lpCmdLine, "%s %d %d", &ImagePath, &quant, &coEff);

	if(SQUARE == 1)
	{
		w = 512;
		h = 512;
	}
	else if(RECTANGULAR == 1)
	{
		w = 352;
		h = 288;
	}

	myImage.setWidth(w);
	myImage.setHeight(h);
	myImage.setQuant(quant);
	myImage.setCoEff(coEff);
	myImage.setImagePath(ImagePath);
	
	myImage.FillInputRGBSpace();

	myImage.GrayScale2YUV();

	if(DCT_ACTIVE == 1)
		myImage.DCTBasedCompDecomp();

	if(IDCT_ACTIVE == 1)
	{
		remove("zigzag.txt");
		myImage.IDCTBasedCompDecomp();
	}

	myImage.YUV2RGB();
	
	if(TESTZIGZAG == 1)
	{
		remove("test.txt");
		myImage.TestZigTheZag();
	}

	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_IMAGE, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_IMAGE);

	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0)) 
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return msg.wParam;
}
开发者ID:shook2012,项目名称:Multimedia-ImageCompression,代码行数:89,代码来源:Image.cpp

示例3: WinMain

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;
	//prepare cos value table
	cosVal[0] = 1; cosVal[1] = cos(PI/16); cosVal[2] = cos(PI/8); cosVal[3] = cos((3*PI)/16);
	cosVal[4] = c; cosVal[5] = cos((5*PI)/16); cosVal[6] = cos((3*PI)/8); cosVal[7] = cos((7*PI)/16);
	cosVal[8] = 0; cosVal[9] = -sin(PI/16); cosVal[10] = -sin(PI/8); cosVal[11] = -sin((3*PI)/16);
	cosVal[12] = -c; cosVal[13] = -sin((5*PI)/16); cosVal[14] = -sin((3*PI)/8); cosVal[15] = -sin((7*PI)/16);

	for(int i = 0; i < 16; ++i){
		cosVal[i+16] = - cosVal[i];
	}

	int wd, ht;
	char ImagePath[_MAX_PATH];
	sscanf(lpCmdLine, "%s %d %d %d", &ImagePath, &quantizationLevel, &deliveryMode, &latency);
	
	if(quantizationLevel > 7 || quantizationLevel < 0){
		MessageBox(NULL, "Quantization Level can be 0 to 7 only.", NULL, NULL);
		return FALSE;
	}
	if(deliveryMode > 3 || deliveryMode < 1){
		MessageBox(NULL, "Delivery Mode can be either 1 2 or 3 only.", NULL, NULL);
		return FALSE;
	}
	if(latency < 0){
		MessageBox(NULL, "Latency can be greater than 0 only.", NULL, NULL);
		return FALSE;
	}

	wd=352; ht=288;	
	originalImage.setWidth(wd);
	originalImage.setHeight(ht);
	originalImage.setImagePath(ImagePath);
	originalImage.ReadImage();
	
	nextStart = wd + 50;
				
	workingImage.setHeight(ht);
	workingImage.setWidth(wd);
	
	Byte* imgd = new Byte[ht*wd*3];
	memset(imgd, 0xFF, sizeof(Byte)*ht*wd*3);
	
	workingImage.setImageData(imgd);
	imgd = NULL;
		
	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_IMAGE, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow)) 
	{
		return FALSE;
	}	
	
	TwoByte *s = new TwoByte[ht*wd*3];
	MyStorage strg;
	strg.setStorage(s);
	encode(s);	

	if(deliveryMode == 1){
		_beginthread (sendDecodeSequentialMode, 0, s);	
	}
	else if(deliveryMode == 2){
		_beginthread (sendSpectralSelection, 0, s);
	}
	else if(deliveryMode == 3){
		_beginthread (sendSuccessiveBits, 0, s);
	}
	

	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_IMAGE);
	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0)) 
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
		
	return msg.wParam;
}
开发者ID:atulkum,项目名称:imageProcessing,代码行数:92,代码来源:Image.cpp


注:本文中的MyImage::setHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。