| 33 | typename image_array_type |
| 34 | > |
| 35 | void make_simple_test_data ( |
| 36 | image_array_type& images, |
| 37 | std::vector<std::vector<rectangle> >& object_locations |
| 38 | ) |
| 39 | /*! |
| 40 | ensures |
| 41 | - #images.size() == 3 |
| 42 | - #object_locations.size() == 3 |
| 43 | - Creates some simple images to test the object detection routines. In particular, |
| 44 | this function creates images with white 70x70 squares in them. It also stores |
| 45 | the locations of these squares in object_locations. |
| 46 | - for all valid i: |
| 47 | - object_locations[i] == A list of all the white rectangles present in images[i]. |
| 48 | !*/ |
| 49 | { |
| 50 | images.clear(); |
| 51 | object_locations.clear(); |
| 52 | |
| 53 | images.resize(3); |
| 54 | images[0].set_size(400,400); |
| 55 | images[1].set_size(400,400); |
| 56 | images[2].set_size(400,400); |
| 57 | |
| 58 | // set all the pixel values to black |
| 59 | assign_all_pixels(images[0], 0); |
| 60 | assign_all_pixels(images[1], 0); |
| 61 | assign_all_pixels(images[2], 0); |
| 62 | |
| 63 | // Now make some squares and draw them onto our black images. All the |
| 64 | // squares will be 70 pixels wide and tall. |
| 65 | |
| 66 | std::vector<rectangle> temp; |
| 67 | temp.push_back(centered_rect(point(100,100), 70,70)); |
| 68 | fill_rect(images[0],temp.back(),255); // Paint the square white |
| 69 | temp.push_back(centered_rect(point(200,300), 70,70)); |
| 70 | fill_rect(images[0],temp.back(),255); // Paint the square white |
| 71 | object_locations.push_back(temp); |
| 72 | |
| 73 | temp.clear(); |
| 74 | temp.push_back(centered_rect(point(140,200), 70,70)); |
| 75 | fill_rect(images[1],temp.back(),255); // Paint the square white |
| 76 | temp.push_back(centered_rect(point(303,200), 70,70)); |
| 77 | fill_rect(images[1],temp.back(),255); // Paint the square white |
| 78 | object_locations.push_back(temp); |
| 79 | |
| 80 | temp.clear(); |
| 81 | temp.push_back(centered_rect(point(123,121), 70,70)); |
| 82 | fill_rect(images[2],temp.back(),255); // Paint the square white |
| 83 | object_locations.push_back(temp); |
| 84 | |
| 85 | // corrupt each image with random noise just to make this a little more |
| 86 | // challenging |
| 87 | dlib::rand rnd; |
| 88 | for (unsigned long i = 0; i < images.size(); ++i) |
| 89 | { |
| 90 | for (long r = 0; r < images[i].nr(); ++r) |
| 91 | { |
| 92 | for (long c = 0; c < images[i].nc(); ++c) |
no test coverage detected