Update to 2.0.0 tree from current Fremantle build
[opencv] / apps / Hawk / demos / cvFitLine.c
diff --git a/apps/Hawk/demos/cvFitLine.c b/apps/Hawk/demos/cvFitLine.c
deleted file mode 100644 (file)
index 0cfed07..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-char wndname01[] = "Source image";\r
-char wndname02[] = "Thrshold image";\r
-char barname01[] = "Threshold factor";\r
-int slider_pos[1] = {0};\r
-\r
-\r
-// Load the source image. HighGUI use.\r
-IPLIMAGE image01 = load_iplimage("image009.bmp");\r
-\r
-// Create the destination images. HighGUI use.\r
-IPLIMAGE image02 = cvCreateImage(cvSize(image01->width, image01->height),\r
-                                image01->depth,\r
-                                1);\r
-\r
-IPLIMAGE image03 = cvCreateImage(cvSize(image01->width, image01->height),\r
-                                image01->depth,\r
-                                1);                           \r
-// Make onechannel image.\r
-cvCvtColor(image01,image03, CV_BGR2GRAY);\r
-                         \r
-\r
-// Create windows. HighGUI use.\r
-named_window(wndname01, 0);\r
-named_window(wndname02, 0);\r
-\r
-// Show the image. HighGUI use.\r
-show_iplimage(wndname01, image03);\r
-\r
-\r
-// Define trackbar callback functon. This function find contours,\r
-// draw it and approximate it by lines.\r
-void func(int h)\r
-{\r
-    CvMemStorage* stor;\r
-    CvSeq* cont;\r
-    float * line;\r
-    CvPoint* PointArray;\r
-    CvPoint2D32f* PointArray2D32f;\r
-    CvPoint FirstPoint;\r
-    CvPoint LastPoint;\r
-        \r
-    // Create dynamic structure and sequence.\r
-    stor = cvCreateMemStorage(0);\r
-    cont = cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvSeq), sizeof(CvPoint) , stor);\r
-    \r
-    // Threshold the source image. This needful for cvFindContours().\r
-    cvThreshold( image03, image02, slider_pos[0], 255, CV_THRESH_BINARY );\r
-    \r
-    // Find all contours.\r
-    cvFindContours( image02, stor, &cont, sizeof(CvContour), \r
-                    CV_RETR_LIST, CV_CHAIN_APPROX_NONE);\r
-    \r
-    // Clear image. IPL use.\r
-    cvSetZero(image02);\r
-    \r
-    // This cycle draw all contours and approximate it by lines.\r
-    for(;cont;cont = cont->h_next)\r
-    {   \r
-        int i; // Indicator of cycle.\r
-        int count = cont->total; // This is number point in contour\r
-        \r
-        \r
-        // Alloc memory for contour point set.    \r
-        PointArray = malloc( count*sizeof(CvPoint) );\r
-        PointArray2D32f= malloc( count*sizeof(CvPoint2D32f) );\r
-        \r
-        // Alloc memory for line data.\r
-        line = malloc(4*sizeof(float));\r
-        // Get contour point set.\r
-        cvCvtSeqToArray(cont, PointArray, CV_WHOLE_SEQ);\r
-        \r
-        // Convert CvPoint set to CvBox2D32f set.\r
-        for(i=0; i<count; i++)\r
-        {\r
-            PointArray2D32f[i].x = PointArray[i].x;\r
-            PointArray2D32f[i].y = PointArray[i].y;\r
-        }\r
-        \r
-        // Fits line to current contour.\r
-        cvFitLine2D(PointArray2D32f,cont->total,CV_DIST_L2,NULL,0.01,0.01,line);\r
-        \r
-        FirstPoint.x=line[2]-100*line[0];\r
-        FirstPoint.y=line[3]-100*line[1];\r
-        \r
-        LastPoint.x=line[2]+100*line[0];\r
-        LastPoint.y=line[3]+100*line[1];\r
-        \r
-        // Draw current contour.\r
-        cvDrawContours(image02,cont,255,255,0,1,8);\r
-        //Fits lines only to sufficiently large contours\r
-        if (cont->total > 50 ) \r
-            cvLine(image02,FirstPoint,LastPoint,150,1,0);\r
-        \r
-        // Free memory.          \r
-        free(PointArray);\r
-        free(PointArray2D32f);\r
-        free(line);\r
-    }\r
-    \r
-    // Show image. HighGUI use. \r
-    show_iplimage(wndname02, image02);\r
-    }\r
-\r
-\r
-func(0);\r
-\r
-// Create toolbars. HighGUI use.\r
-create_trackbar(barname01, wndname02, &slider_pos[0], 255, func);\r
-\r
-\r
-// Wait for a key stroke; the same function arranges events processing                \r
-wait_key(0);\r
-cvReleaseImage(&image01);\r
-cvReleaseImage(&image02);\r
-cvReleaseImage(&image03);\r
-\r
-destroy_window(wndname01);\r
-destroy_window(wndname02);\r
-\r
-                            
\ No newline at end of file