Project

General

Profile

Revision 467

fixed vision more

View differences:

trunk/code/projects/colonet/vision/vision_driver.c
7 7
#include <stdlib.h>
8 8

  
9 9
int main(int argc, char** argv) {
10
  const char* filename = (argc == 2) ? argv[1] : (char*)"colonet.jpg";
10
  char* filename = (argc == 2) ? argv[1] : (char*)"colonet.jpg";
11 11

  
12 12
  printf("vision_init(%s)\n", filename);
13 13

  
......
30 30

  
31 31
  free(positions);
32 32

  
33
  vision_destroy();
34

  
35 33
  return 0;
36 34
}
trunk/code/projects/colonet/vision/vision.c
24 24
};
25 25

  
26 26
static IplImage *image02, *image03, *image04;
27
static char* filename;
27 28

  
28
int vision_init(const char* filename) {
29
int vision_init(char* filename_) {
30
  filename = filename_;
31
  return 0;
32
}
33

  
34
int vision_get_robot_positions(VisionPosition** positions) {
35
  CvMemStorage* stor;
36
  CvSeq* cont;
37
  CvBox2D32f* box;
38
  CvPoint* PointArray;
39
  CvPoint2D32f* PointArray2D32f;
40

  
29 41
  if ((image03 = cvLoadImage(filename, 0)) == 0) {
30 42
    fprintf(stderr, "Failed to load image.\n");
31 43
    return -1;
......
43 55

  
44 56
  if (DEBUG) cvNamedWindow("Result", 1);
45 57

  
46
  return 0;
47
}
48

  
49
void vision_destroy() {
50
  if (DEBUG) cvWaitKey(0);
51

  
52
  cvReleaseImage(&image02);
53
  cvReleaseImage(&image03);
54

  
55
  if (DEBUG) cvDestroyWindow("Result");
56
}
57

  
58
int vision_get_robot_positions(VisionPosition** positions) {
59
  CvMemStorage* stor;
60
  CvSeq* cont;
61
  CvBox2D32f* box;
62
  CvPoint* PointArray;
63
  CvPoint2D32f* PointArray2D32f;
64

  
65 58
  // Create dynamic structure and sequence.
66 59
  stor = cvCreateMemStorage(0);
67 60
  cont = cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvSeq), sizeof(CvPoint) , stor);
......
172 165
    }
173 166
  }
174 167

  
168
  if (DEBUG) cvWaitKey(0);
169

  
170
  cvReleaseImage(&image02);
171
  cvReleaseImage(&image03);
172

  
173
  if (DEBUG) cvDestroyWindow("Result");
174

  
175 175
  // Show image. HighGUI use.
176 176
  if (DEBUG) cvShowImage( "Result", image04 );
177 177

  
trunk/code/projects/colonet/vision/vision.h
10 10
  int y;
11 11
} VisionPosition;
12 12

  
13
int vision_init(const char* filename);
13
int vision_init(char* filename);
14 14
int vision_get_robot_positions(VisionPosition** positions);
15
void vision_destroy();
16 15

  
17 16
#endif
trunk/code/projects/colonet/ColonetServer/PositionMonitor.cpp
43 43
  //TODO: check for error returned
44 44
  int numPositions = vision_get_robot_positions(&positions);
45 45
  printf("numPositions is %d\n", numPositions);
46
  for (int i = 0; i < numPositions; i++) {
47
    printf("{%d,%d} ", positions[i].x, positions[i].y);
48
  }
49
  printf("\n");
46 50

  
51

  
47 52
  /*
48 53
  //TODO: compare current set of positions to previous set of
49 54
  // positions to match up who is who

Also available in: Unified diff