본문 바로가기

Project/증강현실을 이용한 사천성

빨강 추적



분명 중심도 구하고
cvCircle 함수도 썼는데 왜 안되나 했었더니,
원본 영상 이미지를 다시 출력해주는걸 깜박했다ㅋㅋ

이런 어이없는 실수를 ㅋㅋ

void CameraManager::DrawCircle ()
{
	int i = 0;
	int j = 0;
	int counter = 0;
	CvPoint m_ptRed = cvPoint(0, 0);

	CRect rect;
	int x, y;

	this->pDC = this->originalCam->GetDC(); //Picture Box의 영역을 구함
	this->originalCam->GetClientRect(&rect);
	x = rect.top;
	y = rect.left;
	rect.SetRect(x, y, x + CAM_WIDTH, y + CAM_HEIGHT);

	// 중심 구하기
	for (i = 0 ; i < this->camera.Get_ipl_gray_Image()->height ; i++)
	{
		for (j = 0 ; j < this->camera.Get_ipl_gray_Image()->widthStep ; j++)
		{
			if ((this->camera.Get_ipl_gray_Image()->
				imageData[i * this->camera.Get_ipl_gray_Image()->widthStep + j])!=0)
			{
				m_ptRed.x += j;
				m_ptRed.y += i;
				counter++;
			}
		}
	}

	// 원그리기
	if(counter != 0)
	{
		m_ptRed.x = m_ptRed.x / counter;
		m_ptRed.y = m_ptRed.y / counter;
		cvCircle(this->camera.Get_ipl_OriginalImage(), m_ptRed, 20, CV_RGB(255,0,0), 3);
	}

	// Original Image View
	this->camera.Get_cvv_OriginalImage().CopyOf ( this->camera.Get_ipl_OriginalImage() );
	this->camera.Get_cvv_OriginalImage().DrawToHDC(this->pDC->m_hDC, rect);

	this->originalCam->ReleaseDC(this->pDC);
}