学习OpenCV课后题3.4

来源:互联网 发布:淘宝哪个打折软件好用 编辑:程序博客网 时间:2024/05/07 10:56

// Ex3_4.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <cv.h>
#include <cvcam.h>
#include <cxcore.h>
#include <highgui.h>

 

#pragma comment(lib,"cv.lib")
#pragma comment(lib,"cvcam.lib")
#pragma comment(lib,"cxcore.lib")
#pragma comment(lib,"highgui.lib")

 

int main(int argc, char* argv[])
{
 CvMat *Mat = cvCreateMat( atoi(argv[1]), atoi(argv[2]), CV_8UC3);
 cvSetZero(Mat);

 for (int nHeight = 100; nHeight < 300; nHeight++ )
 {
  uchar *ptr = (uchar*)(Mat->data.ptr + nHeight*Mat->step);
  for (int nWidth = 100; nWidth < 300; nWidth++)
  {
   ptr[nWidth*3+1] = 255;
  }
 }

 cvNamedWindow("Show");
 cvShowImage("Show",Mat);

 cvWaitKey();
 
 cvReleaseMat(&Mat);
 cvDestroyWindow("Show");

 return 0;
}

 

原创粉丝点击