#include "PatternMatchDLL.h" #include "find_edges.h" #include "vectorization.h" unsigned char* rgbImage_[5]; int width_, height_; void initPatternMatch(int w, int h) { width_ = w; height_ = h; for(int i=0; i<5; i++) rgbImage_[i] = (unsigned char*)malloc(3*w*h*sizeof(unsigned char)); } int findPattern(int xs[8], int ys[8], unsigned char* rgb, int width, int height) { objectSet objects_; blackAndWhite(rgb, rgbImage_[0], width, height); gaussiano2(rgbImage_[0], rgbImage_[1], width, height); canny(rgbImage_[1], rgbImage_[2], rgbImage_[3], width, height); dilatation(rgbImage_[2], rgbImage_[3], width, height); erosion(rgbImage_[3], rgbImage_[2], width, height); vectorizeMask2(rgbImage_[2], rgbImage_[4], objects_, width, height); getCriticalPoints(objects_, rgb, width, height); if(objects_.size() >= 2) { for(int i=0; i<4; i++) { xs[i] = objects_[0].points[i].x; ys[i] = objects_[0].points[i].y; xs[i+4] = objects_[1].points[i].x; ys[i+4] = objects_[1].points[i].y; } return 1; } return 0; } void finishPatternMatch() { for(int i=0; i<5; i++) free(rgbImage_[i]); }