From 33852c7b378d419be75d15a9663ee6b071c2f534 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Thu, 9 Oct 2008 17:22:12 +0200 Subject: [PATCH] automatic commit --- image.cc | 15 --------------- image.h | 1 - labelled_image.cc | 27 --------------------------- labelled_image.h | 3 --- pi_referential.cc | 15 +++------------ pi_referential.h | 32 +++++++++++++++++--------------- pose.cc | 23 ----------------------- pose.h | 2 -- rich_image.cc | 11 +++-------- rich_image.h | 1 - run.sh | 6 ++++-- 11 files changed, 27 insertions(+), 109 deletions(-) diff --git a/image.cc b/image.cc index e9eb83f..1194f06 100644 --- a/image.cc +++ b/image.cc @@ -34,21 +34,6 @@ Image::~Image() { delete[] _content; } -void Image::crop(int xmin, int ymin, int width, int height) { - ASSERT(xmin >= 0 && xmin + width <= _width && - ymin >= 0 && ymin + height <= _height); - unsigned char *new_content = new unsigned char[width * height]; - for(int y = 0; y < height; y++) { - for(int x = 0; x < width; x++) { - new_content[x + (y * width)] = _content[x + xmin + _width * (y + ymin)]; - } - } - delete[] _content; - _content = new_content; - _width = width; - _height = height; -} - void Image::to_rgb(RGBImage *image) { int c; for(int y = 0; y < _height; y++) { diff --git a/image.h b/image.h index 5ba20a8..8c65017 100644 --- a/image.h +++ b/image.h @@ -50,7 +50,6 @@ public: virtual ~Image(); - virtual void crop(int xmin, int ymin, int width, int height); virtual void to_rgb(RGBImage *image); virtual void read(istream *in); diff --git a/labelled_image.cc b/labelled_image.cc index d02313d..d88e428 100644 --- a/labelled_image.cc +++ b/labelled_image.cc @@ -47,33 +47,6 @@ int LabelledImage::pose_cell_label(PoseCell *cell) { return 0; } -void LabelledImage::crop(int xmin, int ymin, int width, int height) { - RichImage::crop(xmin, ymin, width, height); - for(int t = 0; t < _nb_targets; t++) { - _target_poses[t].translate(- xmin, - ymin); - } -} - -void LabelledImage::reduce() { - int xmin = _width, xmax = 0, ymin = _height, ymax = 0; - if(_nb_targets > 0) { - for(int t = 0; t < _nb_targets; t++) { - xmin = min(xmin, int(_target_poses[t]._bounding_box_xmin)); - ymin = min(ymin, int(_target_poses[t]._bounding_box_ymin)); - xmax = max(xmax, int(_target_poses[t]._bounding_box_xmax)); - ymax = max(ymax, int(_target_poses[t]._bounding_box_ymax)); - } - } else { - xmin = 0; ymin = 0; - xmax = 640; ymax = 480; - } - xmin = max(0, xmin); - ymin = max(0, ymin); - xmax = min(_width, xmax); - ymax = min(_height, ymax); - crop(xmin, ymin, xmax - xmin, ymax - ymin); -} - void LabelledImage::write(ostream *out) { int v = file_format_version; write_var(out, &v); diff --git a/labelled_image.h b/labelled_image.h index 2a26d73..5d23402 100644 --- a/labelled_image.h +++ b/labelled_image.h @@ -43,9 +43,6 @@ public: // it is far enough from any target int pose_cell_label(PoseCell *cell); - void crop(int xmin, int ymin, int width, int height); - void reduce(); - virtual void write(ostream *out); virtual void read(istream *in); }; diff --git a/pi_referential.cc b/pi_referential.cc index 6f56099..c2b716e 100644 --- a/pi_referential.cc +++ b/pi_referential.cc @@ -70,20 +70,10 @@ void PiReferential::draw_frame(RGBImage *image, image->draw_line(2, r, g, b, x3, y3, x4, y4); image->draw_line(2, r, g, b, x4, y4, x1, y1); } else { - // int xc = (x1 + x2 + x3 + x4)/4, yc = (y1 + y2 + y3 + y4)/4; - // image->draw_line(1, r, g, b, xc - delta, yc, xc + delta, yc); - // image->draw_line(1, r, g, b, xc, yc - delta, xc, yc + delta); image->draw_line(2, r, g, b, x1, y1, x2, y2); image->draw_line(2, r, g, b, x2, y2, x3, y3); image->draw_line(2, r, g, b, x3, y3, x4, y4); image->draw_line(2, r, g, b, x4, y4, x1, y1); - // image->draw_line(2, r, g, b, - // (2*xc + 5 * x1 + 5 * x2)/12, (2 * yc + 5 * y1 + 5 * y2)/12, - // (x1 + x2)/2, (y1 + y2)/2); - // image->draw_line(6, r, g, b, - // (2*xc + 3 * x2 + 3 * x3)/8, (2 * yc + 3 * y2 + 3 * y3)/8, - // (x2 + x3)/2, (y2 + y3)/2 - // ); } } @@ -308,6 +298,7 @@ PiReferential::PiReferential(PoseCell *cell) { // Frames if(_body_xc >= _head_xc) { +// if(_belly_xc >= _head_xc) { _horizontal_polarity = 1; } else { _horizontal_polarity = -1; @@ -358,8 +349,8 @@ PiReferential::PiReferential(PoseCell *cell) { scalar_t l = sqrt(_head_belly_vx * _head_belly_vx + _head_belly_vy * _head_belly_vy); - _head_belly_vx = _head_belly_vx/l * _head_radius * 2; - _head_belly_vy = _head_belly_vy/l * _head_radius * 2; + _head_belly_vx = (_head_belly_vx / l) * _head_radius * 2; + _head_belly_vy = (_head_belly_vy / l) * _head_radius * 2; _head_belly_edge_shift = int(floor(- RichImage::nb_edge_tags * atan2(_head_belly_ux, _head_belly_uy) / (2 * M_PI) + 0.5)); _head_belly_edge_shift = (RichImage::nb_edge_tags + _head_belly_edge_shift) % RichImage::nb_edge_tags; } diff --git a/pi_referential.h b/pi_referential.h index 04516f3..d1341ac 100644 --- a/pi_referential.h +++ b/pi_referential.h @@ -46,19 +46,20 @@ class PiReferential { scalar_t _head_ux, _head_uy, _head_vx, _head_vy; scalar_t _head_ux_nopolarity, _head_uy_nopolarity, _head_vx_nopolarity, _head_vy_nopolarity; - // The body frame in that _common_scale. The vectors are of length the radii of the ellipse + // Useless fields, but they are necessary so that the optimized code + // with g++ gives the same results as some reference + // experiments. Sorry for that. scalar_t _body_xc, _body_yc; - scalar_t _body_radius_1, _body_radius_2; +// scalar_t _body_radius_1, _body_radius_2; scalar_t _body_tilt; - // The belly frame is defined by the body location and head scale + // The belly frame is defined by the belly location and head scale scalar_t _belly_xc, _belly_yc; scalar_t _belly_ux, _belly_uy, _belly_vx, _belly_vy; scalar_t _belly_ux_nopolarity, _belly_uy_nopolarity, _belly_vx_nopolarity, _belly_vy_nopolarity; scalar_t _belly_window_scaling; - // The head-belly frame is defined by the head location and the body - // center location + // The head-belly frame is defined by the head location and the belly scalar_t _head_belly_xc, _head_belly_yc; scalar_t _head_belly_ux, _head_belly_uy, _head_belly_vx, _head_belly_vy; int _head_belly_edge_shift; @@ -74,29 +75,30 @@ public: PiReferential(PoseCell *cell); enum { - // A frame centered on the head, of size four times the head radius - // and, flipped verically if the body center is on the left of the - // head center + // A square frame centered on the head, of size four times the + // head radius and, flipped vertically if the belly is on the left + // of the head center RM_HEAD, // Same as above, without the flipping RM_HEAD_NO_POLARITY, - // A frame centered on the body center, of size size times the - // head rardius, flipped vertically if the body center is on the - // left of the head center + + // A frame centered on the belly, of size eight times the head + // radius, flipped vertically if the belly is on the left of the + // head center RM_BELLY, // Same as above, without the flipping RM_BELLY_NO_POLARITY, // A frame centered on the middle point between the head center - // and the body center, of size twice the distance head center - - // body center in the head-body direction, and of four times the - // head radius in the other + // and the belly, of size twice the distance head center - belly + // in the head-belly direction, and of four times the head radius + // in the other RM_HEAD_BELLY, // Same as above with rotation of the edges - RM_HEAD_BELLY_EDGES, + RM_HEAD_BELLY_EDGES }; int common_scale(); diff --git a/pose.cc b/pose.cc index f0aa9d3..989f685 100644 --- a/pose.cc +++ b/pose.cc @@ -29,29 +29,6 @@ void Pose::horizontal_flip(scalar_t scene_width) { _belly_xc = scene_width - 1 - _belly_xc; } -void Pose::translate(scalar_t dx, scalar_t dy) { - _bounding_box_xmin += dx; - _bounding_box_ymin += dy; - _bounding_box_xmax += dx; - _bounding_box_ymax += dy; - _head_xc += dx; - _head_yc += dy; - _belly_xc += dx; - _belly_yc += dy; -} - -void Pose::scale(scalar_t factor) { - _bounding_box_xmin *= factor; - _bounding_box_ymin *= factor; - _bounding_box_xmax *= factor; - _bounding_box_ymax *= factor; - _head_xc *= factor; - _head_yc *= factor; - _head_radius *= factor; - _belly_xc *= factor; - _belly_yc *= factor; -} - const scalar_t tolerance_scale_ratio_for_hit = 1.5; const scalar_t tolerance_distance_factor_for_hit = 1.0; diff --git a/pose.h b/pose.h index 8362d1d..300aba1 100644 --- a/pose.h +++ b/pose.h @@ -35,8 +35,6 @@ public: bool collide(int level, Pose *pose); void horizontal_flip(scalar_t scene_width); - void translate(scalar_t dx, scalar_t dy); - void scale(scalar_t factor); void draw(int thickness, int r, int g, int b, int level, RGBImage *image); diff --git a/rich_image.cc b/rich_image.cc index f3b4b54..e1d2112 100644 --- a/rich_image.cc +++ b/rich_image.cc @@ -88,7 +88,7 @@ void RichImage::compute_one_scale_edge_maps(int width, int height, } } - const unsigned int var_square_size = 16; + const int var_square_size = 16; int k00 = - 2 + width * (- 2); int k01 = - 1 + width * (- 2); @@ -148,13 +148,13 @@ void RichImage::compute_one_scale_edge_maps(int width, int height, y - int(var_square_size/2) >= 0 && y + int(var_square_size/2) < height) { - unsigned int s = + int s = + local_sum_pixel_map[ - var_square_size/2 + width * ( - var_square_size / 2)] + local_sum_pixel_map[ + var_square_size/2 + width * ( + var_square_size / 2)] - local_sum_pixel_map[ - var_square_size/2 + width * ( + var_square_size / 2)] - local_sum_pixel_map[ + var_square_size/2 + width * ( - var_square_size / 2)]; - unsigned int s_sq = + int s_sq = + local_sum_sq_pixel_map[ - var_square_size/2 + width * ( - var_square_size / 2)] + local_sum_sq_pixel_map[ + var_square_size/2 + width * ( + var_square_size / 2)] - local_sum_sq_pixel_map[ - var_square_size/2 + width * ( + var_square_size / 2)] @@ -384,11 +384,6 @@ void RichImage::compute_rich_structure() { delete[] scale_pixel_maps; } -void RichImage::crop(int xmin, int ymin, int width, int height) { - free(); - Image::crop(xmin, ymin, width, height); -} - RichImage::RichImage() : Image() { _width_at_scale = 0; _height_at_scale = 0; diff --git a/rich_image.h b/rich_image.h index c8f7a74..2d9bd6b 100644 --- a/rich_image.h +++ b/rich_image.h @@ -91,7 +91,6 @@ public: virtual ~RichImage(); virtual void compute_rich_structure(); - virtual void crop(int xmin, int ymin, int width, int height); virtual void write(ostream *out); diff --git a/run.sh b/run.sh index bd12a37..2900f5e 100755 --- a/run.sh +++ b/run.sh @@ -30,6 +30,7 @@ fi echo +###################################################################### # Generating the pool file DATA_PATH=./rmk-data @@ -69,12 +70,13 @@ if [[ -d ${DATA_PATH} ]]; then else - echo "Can not find the RateMyKitten images in ${DATA_PATH}. You can" >&2 - echo "download them from ${MAIN_URL}" >&2 + echo "Can not find the RateMyKitten images in ${DATA_PATH}. You can download" >&2 + echo "them from ${MAIN_URL}" >&2 exit 1 fi +###################################################################### # Running the computation per se RESULT_DIR=./results -- 2.20.1