::Point> > shrink_poly_tmps;
        shrink_poly_tmps.push_back(shrinked_poly[poly_idx]);
        cv::fillPoly(conf_origin_tmp, shrink_poly_tmps, 1);

        float center_x, center_y, sigma;
        if (label_shape == 1)
		{
		    // If generate score map in Gaussian mode, we need to calculate the center point and sigma
			vector<cv::Point> shrink_poly_tmp = shrinked_poly[poly_idx];
			float shrinked_four_side[4] = { 0 };
			for (int p_idx = 0; p_idx < 4; ++p_idx)
			{
				shrinked_four_side[p_idx] = sqrt(pow(shrink_poly_tmp[p_idx].x - shrink_poly_tmp[p_idx + 1 > 3? 0 : p_idx + 1].x, 2)
				                 + pow(shrink_poly_tmp[p_idx].y - shrink_poly_tmp[p_idx + 1 > 3? 0 : p_idx + 1].y, 2));;
			}
			float shrink_poly_h = MAX(shrinked_four_side[1], shrinked_four_side[3]);
			float shrink_poly_w = MAX(shrinked_four_side[0], shrinked_four_side[2]);

			sigma = MAX(shrink_poly_h, shrink_poly_w) / 2 * 0.7485;
			center_x = (shrink_poly_tmp[0].x + shrink_poly_tmp[1].x + shrink_poly_tmp[2].x + shrink_poly_tmp[3].x) / 4.;
			center_y = (shrink_poly_tmp[0].y + shrink_poly_tmp[1].y + shrink_poly_tmp[2].y + shrink_poly_tmp[3].y) / 4.;
		}

		if (geometry == 0)
		{
		    /********** RBOX **********/
			cv::RotatedRect rbox = cv::minAreaRect(point_tmp);
			cv::Point2f vertices[4];
			rbox.points(vertices);
			float angle = rbox.angle;

			// Switch order
			cv::Point2f min_area_box[4];
			if (abs(angle) > 45.0)
			{
				angle = -(90.0 + angle) / 180.0*3.1415926535897;
				min_area_box[0] = vertices[2];
				min_area_box[1] = vertices[3];
				min_area_box[2] = vertices[0];
				min_area_box[3] = vertices[1];
			}
			else
			{
				angle = abs(angle) / 180.0*3.1415926535897;
				min_area_box[0] = vertices[1];
				min_area_box[1] = vertices[2];
				min_area_box[2] = vertices[3];
				min_area_box[3] = vertices[0];
			}

            // Generate final gt target for each box
			for (int h = 0; h < out_height_; ++h)
			{
				for (int w = 0; w < out_width_; ++w)
				{
					if (conf_origin_tmp.at<float>(h * pool_ratio, w * pool_ratio) == 1)
					{
					     // generate score map for each bbox
						if (label_shape == 1)
						{
						    // if using gaussian score map
							gt_score_map[h*out_width_ + w] = exp(-0.5 / pow(sigma, 2) * (pow(h*pool_ratio - center_y, 2) + pow(w*pool_ratio - center_x, 2)));
						}
						else
						{
						    // if using normal score map
						    gt_score_map[h*out_width_ + w] = 1;
						}

                        // generate geo map for each bbox
						gt_geo_data[0*out_height_*out_width_ + h*out_width_ + w] = (float)distance_to_Line(min_area_box[0], min_area_box[1], cv::Point2f(w * pool_ratio, h * pool_ratio));
						gt_geo_data[1*out_height_*out_width_ + h*out_width_ + w] = (float)distance_to_Line(min_area_box[1], min_area_box[2], cv::Point2f(w * pool_ratio, h * pool_ratio));
						gt_geo_data[2*out_height_*out_width_ + h*out_width_ + w] = (float)distance_to_Line(min_area_box[2], min_area_box[3], cv::Point2f(w * pool_ratio, h * pool_ratio));
						gt_geo_data[3*out_height_*out_width_ + h*out_width_ + w] = (float)distance_to_Line(min_area_box[3], min_area_box[0], cv::Point2f(w * pool_ratio, h * pool_ratio));
						gt_geo_data[4*out_height_*out_width_ + h*out_width_ + w] = (float)angle;

						for (int k = 0; k < 5; k++)
						{
							gt_geo_weight[k*out_height_*out_width_ + h*out_width_ + w] = 1;
						}

					}
				}
			}

		}
	    else if (geometry == 1)
	    {
	        /********** QUAD **********/
            float four_side[4] = { 0 };
			for (int p_idx = 0; p_idx < 4; ++p_idx)
			{
				four_side[p_idx] = sqrt(pow(point_tmp[p_idx].x - point_tmp[(p_idx + 1) % 4].x, 2)
				                +  pow(point_tmp[p_idx].y - point_tmp[(p_idx + 1)%4].y, 2));
			}

			 // Generate final gt target for each box
			for (int h = 0; h < out_height_; ++h)
			{
				for (int w = 0; w < out_width_; ++w)
				{
					if (conf_origin_tmp.at<float>(h * pool_ratio, w * pool_ratio) == 1)
					{
					     // generate score map for each bbox
						if (label_shape == 1)
						{
						    // if using gaussian score map
							gt_score_map[h*out_width_ + w] = exp(-0.5 / pow(sigma, 2) * (pow(h*pool_ratio - center_y, 2) + pow(w*pool_ratio - center_x, 2)));
						}
						else
						{
						    // if using normal score map
						    gt_score_map[h*out_width_ + w] = 1;
						}

                        // generate geo map for each bbox
                        for (int k = 0; k < 4; ++k )
                        {
                            gt_geo_data[2*k*out_height_*out_width_ + h*out_width_ + w] = point_tmp[k].x - w*pool_ratio;
                            gt_geo_data[(2*k+1)*out_height_*out_width_ + h*out_width_ + w] = point_tmp[k].y - h*pool_ratio;

                            // Balance large text and small text according to their side length
                            float min_side = four_side[k]<four_side[(k + 1) % 4]? four_side[k] : four_side[(k + 1) % 4];
                            gt_geo_weight[2*k*out_height_*out_width_ + h*out_width_ + w] = 1./(min_side + 1e-7);
                            gt_geo_weight[(2*k+1)*out_height_*out_width_ + h*out_width_ + w] = 1./(min_side + 1e-7);
                        }
					}
				}
			}
	    }
	}
	balance_BF(gt_score_map, ignore_ratio, gt_score_map_mask, out_height_, out_width_);
}




	