Project

General

Profile

Revision 938

Added by Ryan Cahoon over 15 years ago

OpenCV now works directly with firewire, coriander is not needed
New vision algorithm integrated, a few issues left with algorithm that
tracks the movement of a specific robot
Removed experimental interface to send images over commands socket
--plan to use php in webserver instead
Separated processing of client requests into a separate thread
Fixed bugs updating UI of java client

View differences:

vision.c
3 3
 * based on opencv's sample program fitellipse.c by Denis Burenkov
4 4
 *
5 5
 * @author Rich Hong
6
 * @author Ryan Cahoon
6 7
 * @date 11/18/2007
7 8
 */
9
 
10
//TODO: Add camera stabilization
8 11

  
9 12
#include "vision.h"
10 13

  
......
32 35
int vision_init(/*char* filename_*/) {
33 36
  /*filename = filename_;*/
34 37
  
35
  //TODO: replace with 1394 capture so we don't have to use Coriander
36
  capture = cvCreateCameraCapture(-1);
38
  printf("Vision init. %s\n", DEBUG ? "Debugging on" : "");
39

  
40
  capture = cvCaptureFromCAM(0);
37 41
  if( !capture ) {
38 42
    fprintf( stderr, "ERROR: capture is NULL \n" );
39 43
    return -1;
40 44
  }
41 45

  
42 46
  if (DEBUG)
43
    cvNamedWindow("Result", CV_WINDOW_AUTOSIZE);
47
  {
48
    printf("Vision debugging start\n");
49
    cvNamedWindow("mywindow1", CV_WINDOW_AUTOSIZE);
50
  }
44 51
  
45 52
  return 0;
46 53
}
......
48 55
void vision_close()
49 56
{
50 57
  if (DEBUG)
51
    cvDestroyWindow("Result");
58
    cvDestroyWindow("mywindow1");
52 59

  
53 60
  cvReleaseCapture(&capture);
61
  
62
  printf("Vision closed.\n");
54 63
}
55 64

  
56 65
int getImageBytes(unsigned char *buffer, int length)
......
96 105

  
97 106
    if (DEBUG) cvCircle( image03, center, 3, CV_RGB(255,255,255), -1, 8, 0 );
98 107

  
99
    float dist = MIN_PADDING;
108
    int dist2 = MIN_PADDING;
100 109
    int loc = count;
101 110

  
102 111
    int j;
......
104 113
    {
105 114
      int dx = centers[j].center.x-center.x;
106 115
      int dy = centers[j].center.y-center.y;
107
      float d = cvSqrt(dx*dx + dy*dy);
116
      int d2 = dx*dx + dy*dy;
108 117

  
109
      if (d < dist)
118
      if (d2 < dist2)
110 119
      {
111
        dist = d;
120
        dist2 = d2;
112 121
        loc = j;
113 122
      }
114 123
    }
......
127 136
      cvCircle( image03, centers[i].center, 60, CV_RGB(255,255,255), 3, 8, 0 );
128 137
    }
129 138

  
130
    cvShowImage( "Result", image03 );
139
    cvShowImage( "mywindow1", image03 );
131 140
  }
132 141

  
133 142
  cvReleaseMemStorage(&storage);

Also available in: Unified diff