現在我控制機器人運行井字棋遊戲
但我不知道如何使用opencv庫來識別遊戲板和內部廣場
我不知道如何使用algoritm獲得遊戲板和9X9遊戲廣場的一角使用opencv的井字遊戲,但我可以停止當識別遊戲板
這是我做的拿到角球
二值圖像:
個cvFindContours:
#include <stdio.h>
#include <fcntl.h>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
int main(void){
IplImage *img=NULL;
IplImage *gray=NULL;
CvMemStorage* contour_storage;
CvSeq* contours=NULL;
CvPoint2D32f *corners;
img = cvLoadImage("tictactoe.bmp",CV_LOAD_IMAGE_COLOR);
gray = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1);
cvSmooth(img, img, CV_GAUSSIAN, 3, 0, 0, 0);
cvCvtColor(img, gray, CV_RGB2GRAY);
cvAdaptiveThreshold(gray, gray, 128,CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY_INV, 3, 5);
cvNamedWindow("Threshold", CV_WINDOW_AUTOSIZE);
cvShowImage("Threshold", gray);
contour_storage = cvCreateMemStorage(0);
corners = (CvPoint2D32f *)malloc(sizeof(CvPoint2D32f)*9);
cvFindContours(gray, contour_storage, &contours, sizeof (CvContour), CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));
cvDrawContours(img, contours, CV_RGB(255,0,0), CV_RGB(0,255,0), 2, 4, 8, cvPoint(0,0));
cvNamedWindow("Calibration", CV_WINDOW_AUTOSIZE);
cvShowImage("Calibration", img);
cvWaitKey(0);
return 0;
}
我不知道如何處理圖像處理以執行遊戲
這Progmram僅限於使用C代碼和OpenCV 1.x的運行使用臂嵌入板
請讓我知道如何使用opencv開發此遊戲