Ejemplo n.º 1
0
void wrl::constraint::click(const vec3& p, const vec3& v)
{
    mouse_p = p;
    mouse_v = v;
    calc_rot(mouse_a, mouse_d, p, v);
    calc_pos(mouse_x, mouse_y, p, v);
}
Ejemplo n.º 2
0
void OSD::write_S(uint8_t c){
  if(c == 0xff){
    row++;
    calc_pos();
  } else
    write_raw(c);
}
Ejemplo n.º 3
0
void
Pingus::update_walk (float delta)
{
  float velocity = 70.0f;

  //std::cout << "Updating Walk: " << edge_path_position << "/" << edge_path_length << std::endl;
  // Update the edge_path_position
  edge_path_position += velocity * delta;

  if (edge_path_position > edge_path.length()) // target reached
  {
    if (node_path.empty ()) // final target reached
    {
      current_node = target_node;
      final_target_node = NoNode;
    }
    else // edge is traveled, now go to the next node
    {
      update_edge_path();
    }
  }

  // Recalc pingu position on the screen
  last_pos = pos;
  pos = calc_pos ();
}
Ejemplo n.º 4
0
//-------- Begin of function PieChart::set_font ------------//
//!
void PieChart::set_font(Font *fontPtr) {
    if (!init_flag)
	return;

    font_ptr = fontPtr;

    calc_pos();
}
Ejemplo n.º 5
0
void OSD::write_S(uint8_t c){
  
  if(c == '|'){
    row++;
    calc_pos();
  } else {
    osdbuf[bufpos++] = c;
  } 
}
Ejemplo n.º 6
0
void vsx_widget_split_panel::i_draw()
{
  calc_size();
  vsx_vector3<> p = calc_pos();
  if (render_type == render_2d)
  p.z = 0.0f;
  if (orientation == VSX_WIDGET_SPLIT_PANEL_VERT) {
    sy = size.y-splitter_size;
    float sx = size.x;

    if (fabsf(two->size_min.y) > 0.0f) {
      if (sy*(1-split_pos) < two->size_min.y) {
        split_pos = (sy-two->size_min.y)/sy;
      }
    }
    if (fabsf(two->size_max.y) > 0.0f) {
      if (sy*(1-split_pos) > two->size_max.y) {
        split_pos = (sy-two->size_max.y)/sy;
      }
    }

    if (fabsf(one->size_min.y) > 0.0f) {
      if (sy*(split_pos) < one->size_min.y) {
        split_pos = (one->size_min.y)/sy;
      }
    }
    if (fabsf(one->size_max.y) > 0.0f) {
      if (sy*(split_pos) > two->size_max.y) {
        split_pos = (one->size_max.y)/sy;
      }
    }
      
    two->target_size.x = sx;
    two->target_size.y = sy*(1-split_pos);
    two->size = two->target_size;


    one->target_size.x = sx;
    one->target_size.y = sy*split_pos;
    one->size = one->target_size;
      
    one->target_pos.x = 0;
    one->target_pos.y = -target_size.y*0.5f + 0.5f*split_pos*sy;
    one->target_pos.z = pos.z;
    one->pos = one->target_pos;

    two->target_pos.x = 0;
    two->target_pos.y = target_size.y*0.5f - 0.5f*(1.0f-split_pos)*sy;
    two->target_pos.z = pos.z;
    two->pos = two->target_pos;

    glColor4f(1,1,1,1);
    if (!FLOAT_EQUALS(splitter_size, 0) )
    draw_box(p+vsx_vector3<>(0,split_pos*sy),sx,splitter_size);
  }
}
Ejemplo n.º 7
0
// screen size is 30 cols * 16 rows
void OSD::setPanel(uint8_t st_col, uint8_t st_row){
    col = st_col & 0x1f; // 30 cols - col,row нужны для отработки перевода строки с сохранением колонки
    row = st_row & 0x0f; // 16 rows - в старших битах флаги, размер экрана все равно мелкий


    if(getMode()==0 && row >6) // ntsc after middle - only once per panel
	row-=3;

    calc_pos();
}
Ejemplo n.º 8
0
std::string Breakpoint::to_string(RefVector ref) {

	std::stringstream ss;
	ss << "(";
	ss << get_chr(get_coordinates().start.min_pos, ref);
	ss << ":";
	ss << calc_pos(get_coordinates().start.min_pos, ref);
	ss << "-";
	ss << get_chr(get_coordinates().stop.max_pos, ref);
	ss << ":";
	ss << calc_pos(get_coordinates().stop.max_pos, ref);
	ss << " ";
	ss << positions.support.size();
	ss << " ";
	ss << this->sv_debug;
	ss << " ";
	ss << this->get_strand(2);
	ss << "\n";
	int num = 0;
	for (std::map<std::string, read_str>::iterator i = positions.support.begin(); i != positions.support.end() && num < Parameter::Instance()->report_n_reads; i++) {
		ss << "\t";
		ss << (*i).first;
		ss << " ";
		ss << (*i).second.type;
		if ((*i).second.strand.first) {
			ss << "+";
		} else {
			ss << "-";
		}
		if ((*i).second.strand.second) {
			ss << "+";
		} else {
			ss << "-";
		}
		num++;
		ss << "\n";
	}
	ss << " ";
	return ss.str();
}
Ejemplo n.º 9
0
void vsx_widget_base_editor::i_draw() {
  calc_pos();
  calc_size();
  //vsx_widget_panel::base_draw();
  float db15 = dragborder*2.5f;
  scrollbar_horiz->set_pos(vsx_vector(-size.x*0.5,-size.y*0.5));
  scrollbar_horiz->set_size(vsx_vector(target_size.x-db15, db15));
  scrollbar_horiz->scroll_window_size = editor->scroll_x_size;

  scrollbar_vert->set_pos(vsx_vector(size.x*0.5-db15,-size.y*0.5+db15));
  scrollbar_vert->set_size(vsx_vector(db15,target_size.y-scrollbar_horiz->size.y));
  scrollbar_vert->scroll_window_size = editor->scroll_y_size;
  editor->set_pos(vsx_vector(-scrollbar_vert->size.x*0.5f,scrollbar_horiz->size.y*0.5f));

  editor->target_size.x = target_size.x-scrollbar_vert->size.x;
  editor->target_size.y = target_size.y-scrollbar_horiz->size.y;
}
Ejemplo n.º 10
0
ShipPart2::ShipPart2(Ship *creator, SpaceSprite *osprite,
double oangle, Vector2 orelpos, Vector2 opivot, double omass)
:
SpaceObject(creator, creator->pos, oangle, osprite),
mother(creator)
{
	STACKTRACE;
	layer = LAYER_SHIPS;
	set_depth(DEPTH_SHOTS);

	// angle relative to the mother ship (sprite angle = mother angle + rel. angle)
	offset_angle = oangle;

	// the point relative to center of this sprite, rotation is around this point
	// The pi/2 rotation is needed, since the vectors are declared along y as if angle=0 there,
	// instead angle=0 along x.
	pivot_point = rotate(opivot, PI/2);

	// position of the pivot point relative to mothership central position
	offset_pos = rotate(orelpos, PI/2);

	// just here so that you can override this, if needed.
	ship_rotations = 64;

	// mass, should be non-zero to allow for collisions; the bigger the mass, the less
	// it'll "move" out of position due to collisions
	//	mass = omass;
	mass = ship->mass;			 // might be better ?

	// ok, override earlier settings now
	calc_angle();
	calc_pos(mother->pos);

	collide_flag_anyone = mother->collide_flag_anyone;
	//collide_flag_anyone = ALL_LAYERS;
	//collide_flag_anyone = 1<<LAYER_SHIPS - 1<<LAYER_SHOTS;
	//collide_flag_sameteam = mother->collide_flag_sameteam;
	collide_flag_sameteam = 0;
	collide_flag_sameship = 0;

	hascollided = 0;
	change_pos = 0;
	change_vel = 0;
}
Ejemplo n.º 11
0
void ShipPart::calculate_manager(Vector2 refpos, Vector2 refvel)
{
	STACKTRACE;

	if (!(mother && mother->exists())) {
		mother = 0;
		state = 0;
		return;
	}

	calc_angle();				 // update (angle) using mother settings
	calc_pos(refpos);			 // update (pos) using manager settings
	vel = refvel;

	//sprite_index = get_index(angle);

	SpaceObject::calculate();

}
Ejemplo n.º 12
0
void allocator<T>::deallocate(pointer p, size_type n)
{
	const size_type nb = n * sizeof(T);
#	if DEBUG_SMA_TRACE_INTERFACE
	std::cout << "dealloc " << nb << " bytes (n=" << n << ", pointer=" << static_cast<void *>(p) <<")" << std::endl;
#	endif
	assert(nb > 0);
	const size_type pos = calc_pos(memstart, p);
	assert(0 <= pos && pos < memfree->size());
	auto mask = create_mask(nb, memfree->size()) << pos;
#	if DEBUG_SMA_TRACE_MEMALLOCATION
	std::cout << "freeed memory: " << mask.count() << " bytes -> "
		  << (memfree->count() + mask.count()) << " bytes free."
		  << std::endl;
#	endif
	*memfree = free_memory(*memfree, std::move(mask));
#	if DEBUG_SMA_TRACE_MEMALLOCATION
	print_free_memory();
#	endif
}
Ejemplo n.º 13
0
or_ent *or_map::entity_add (or_ent_type *_ent_type, uint32_t tile_c,
        bool collide_, int32_t x, int32_t y) {
    if (! _ent_type)
        return nullptr;

    auto _ent = new or_ent (this);
    _ent->_ent_type = _ent_type;
    _ent->tile_c = tile_c;
    _ent->collide_ = collide_;
    _ent->x = x;
    _ent->y = y;
    _ent->x_f = (float)x;
    _ent->y_f = (float)y;

    _ent->calc_pos ();
    _ent->calc_size ();

    this->ents.push_back (_ent);
    return _ent;
}
Ejemplo n.º 14
0
void vsx_widget_panel::base_draw() {
  calc_size();
  vsx_vector3<> p = calc_pos();
  //vsx_color b(0,0,0,0), w(0,0,0,1), gr(0,1,0,1), r(1,0,0,1);
  vsx_color<> b(0,0,0,0);
  vsx_color<> w(0,0,0,1);
  //draw_box_gradient(p, dragborder, target_size.y, skin_color[0], skin_color[1], skin_color[1], skin_color[0]);

  draw_box_gradient(p, (float)dragborder, target_size.y, vsx_widget_skin::get_instance()->get_color(0), vsx_widget_skin::get_instance()->get_color(1), vsx_widget_skin::get_instance()->get_color(1), vsx_widget_skin::get_instance()->get_color(0));

  //  draw_box_gradient(p, target_size.x, dragborder, r, b, b, r);
  draw_box_gradient(p, target_size.x, (float)dragborder, w, b, b, w);
  p.y += size.y - (float)dragborder;
  draw_box_gradient(p, target_size.x, (float)dragborder, vsx_widget_skin::get_instance()->get_color(0), vsx_widget_skin::get_instance()->get_color(0), vsx_widget_skin::get_instance()->get_color(1), vsx_widget_skin::get_instance()->get_color(1));

  //  draw_box_gradient(p, target_size.x, dragborder, skin_color[0], skin_color[0], skin_color[1], gr);
  p.x += size.x - (float)dragborder;

  //p.y +=
  //draw_box_gradient(p, dragborder, -(target_size.y-dragborder), gr, skin_color[0], skin_color[1], skin_color[1]);
}
vec2 PROJECTILE::get_pos(float time)
{
	float curvature = 0;
	float speed = 0;
	if(type == WEAPON_GRENADE)
	{
		curvature = tuning.grenade_curvature;
		speed = tuning.grenade_speed;
	}
	else if(type == WEAPON_SHOTGUN)
	{
		curvature = tuning.shotgun_curvature;
		speed = tuning.shotgun_speed;
	}
	else if(type == WEAPON_GUN)
	{
		curvature = tuning.gun_curvature;
		speed = tuning.gun_speed;
	}
	
	return calc_pos(pos, direction, curvature, speed, time);
}
Ejemplo n.º 16
0
bool wrl::constraint::point(const vec3& p, const vec3& v, mat4& A)
{
    if (to_degrees(acos(mouse_v * v)) > 1.0)
    {
        if (mode)
        {
            double a;
            double d;

            calc_rot(a, d, p, v);

            if (fabs(a - mouse_a) > 0.0 || fabs(d - mouse_d) > 0.0)
            {
                A = translation( wvector(T))
                    *    rotation( zvector(T), to_radians(a - mouse_a))
                    * translation(-wvector(T));

                return true;
            }
        }
        else
        {
            double x;
            double y;

            calc_pos(x, y, p, v);

            if (fabs(x - mouse_x) > 0.0 || fabs(y - mouse_y) > 0.0)
            {
                A = translation(xvector(T) * (x - mouse_x)
                                + yvector(T) * (y - mouse_y));
                return true;
            }
        }
    }
    return false;
}
Ejemplo n.º 17
0
Archivo: edit.c Proyecto: vigna/ne
int shift(buffer * const b, char *p, char *msg, int msg_size) {
	const bool use_tabs = b->opt.tabs && b->opt.shift_tabs;
	const int64_t init_line = b->cur_line, init_pos = b->cur_pos, init_y = b->cur_y;

	line_desc *ld = NULL, *start_line_desc = NULL;
	int64_t shift_size = 1;
	char dir = '>';
	int shift_mag = b->opt.tab_size, rc = 0;

	/* Parse parm p; looks like [<|>] ### [s|t], but we allow them
	   in any order, once, with optional white space. */
	if (p) {
		int dir_b = 0, size_b = 0, st_b = 0;
		while (*p) {
			if (isasciispace(*p)) p++;
			else if (!dir_b && (dir_b = (*p == '<' || *p == '>'))) dir = *p++;
			else if (!size_b && (size_b = isdigit((unsigned char)*p))) {
				errno = 0;
				shift_size = strtoll(p, &p, 10);
				if (errno) return INVALID_SHIFT_SPECIFIED;
			} else if (!st_b && (st_b = (*p == 's' || *p == 'S'))) {
				shift_mag = 1;
				p++;
			} else if (!st_b && (st_b = (*p == 't' || *p == 'T'))) p++;
			else return INVALID_SHIFT_SPECIFIED;
		}
	}
	shift_size *= max(1, shift_mag);
	if (shift_size == 0) return INVALID_SHIFT_SPECIFIED;

	int64_t first_line = b->cur_line, last_line = b->cur_line, left_col = 0;

	if (b->marking) {
		if (b->mark_is_vertical) left_col = min(calc_width(b->cur_line_desc, b->block_start_pos, b->opt.tab_size, b->encoding),
		                                        calc_width(b->cur_line_desc, b->cur_pos,         b->opt.tab_size, b->encoding));
		first_line = min(b->block_start_line, b->cur_line);
		last_line  = max(b->block_start_line, b->cur_line);
	}

	/* If we're shifting left (dir=='<'), verify that we have sufficient white space
	   to remove on all the relevant lines before making any changes, i. */

	if (dir == '<') {
		shift_size = -shift_size; /* signed shift_size now also indicates direction. */
		for (int64_t line = first_line; !rc && line <= last_line; line++) {
			int64_t pos;
			goto_line(b, line);
			pos = calc_pos(b->cur_line_desc, left_col, b->opt.tab_size, b->encoding);
			while (pos < b->cur_line_desc->line_len &&
			       left_col - calc_width(b->cur_line_desc, pos, b->opt.tab_size, b->encoding) > shift_size) {
				if (isasciispace(b->cur_line_desc->line[pos]))
					pos = next_pos(b->cur_line_desc->line, pos, b->encoding);
				else {
					rc = INSUFFICIENT_WHITESPACE;
					break;
				}
			}
		}
	}


	if (!rc) {
		start_undo_chain(b);
		for (int64_t line = first_line; line <= last_line; line++) {
			int64_t pos, c_pos, c_col_orig, offset;
			b->attr_len = -1;
			goto_line(b, line);
			b->cur_pos = -1;
			ld = b->cur_line_desc;
			if (line == first_line) start_line_desc = ld;
			pos = calc_pos(ld, left_col, b->opt.tab_size, b->encoding);
			/* If left_col is in the middle of a tab, pos will be on that tab. */
			/* whitespace adjustment strategy:
			   1. Starting from left_col, advance to the right to the first non-blank character C.
			   2. Note C's col. The desired new column is this value +/- shift_size.
			   3. Move left looking for the first tab or non-whitespace or the left_col, whichever comes first.
			      Whitespace changes all take place at that transition point.
			   4. While C's col is wrong
			        if C's col is too far to the right,
			          if we're on a space, delete it;
			          else if there's a tab to our left, delete it;
			          else we should not have started, because it's not possible!
			        if C's col is too far to the left,
			           if its needs to be beyond the next tab stop,
			             insert a tab and move right;
			           else insert a space. */
			/* 1. */
			while (pos < ld->line_len && isasciispace(ld->line[pos]))
				pos = next_pos(ld->line, pos, b->encoding);
			if (pos >= ld->line_len) continue; /* We ran off the end of the line. */
			/* line[pos] should be the first non-blank character. */
			/* 2. */
			c_pos = pos;
			c_col_orig = calc_width(ld, c_pos, b->opt.tab_size, b->encoding);
			/* 3. */
			while (pos && ld->line[pos-1] == ' ')
				pos = prev_pos(ld->line, pos, b->encoding);
			/* If pos is non-zero, it should be on a blank, with only blanks between here and c_pos. */
			/* 4. */
			/* offset = how_far_we_have_moved - how_far_we_want_to_move. */
			while (!stop && (offset = calc_width(ld, c_pos, b->opt.tab_size, b->encoding)-c_col_orig - shift_size)) {
				if (offset > 0) { /* still too far right; remove whitespace */
					if (ld->line[pos] == ' ') {
						delete_stream(b, ld, b->cur_line, pos, 1);
						c_pos--;
					}
					else if (pos) { /* should be a tab just to our left */
						pos = prev_pos(ld->line, pos, b->encoding); /* now we're on the tab */
						if (ld->line[pos] == '\t') {
							delete_stream(b, ld, b->cur_line, pos, 1);
							c_pos--;
						}
						else break; /* Should have been a tab. This should never happen! Give up on this line and go mangle the next one. */
					}
					else break; /* This should never happen; give up on this line and go mangle the next one. */
				}
				else if (offset < 0) { /* too far left; insert whitespace */
					char c = ' ';
					if (use_tabs && (b->opt.tab_size - calc_width(ld, pos, b->opt.tab_size, b->encoding) % b->opt.tab_size) <= -offset )
						c = '\t';
					if (insert_one_char(b, ld, b->cur_line, pos, c)) {
						break;
					}
					pos++;
					c_pos++;
				}
			}
		}
		end_undo_chain(b);
		if (b->syn) {
			b->attr_len = -1;
			need_attr_update = true;
			update_syntax_states(b, -1, start_line_desc, (line_desc *)ld->ld_node.next);
		}
		update_window_lines(b, b->top_line_desc, 0, ne_lines - 2, false);
	}

	/* put the screen back where way we found it. */
	goto_line_pos(b, init_line, init_pos);
	delay_update();
	const int64_t avshift = b->cur_y - init_y;
	if (avshift) {
		snprintf(msg, msg_size, "%c%" PRId64, avshift > 0 ? 'T' :'B', avshift > 0 ? avshift : -avshift);
		adjust_view(b, msg);
	}

	return rc;
}
Ejemplo n.º 18
0
void ITEMS::render_projectile(const NETOBJ_PROJECTILE *current, int itemid)
{

	// get positions
	float curvature = 0;
	float speed = 0;
	if(current->type == WEAPON_GRENADE)
	{
		curvature = gameclient.tuning.grenade_curvature;
		speed = gameclient.tuning.grenade_speed;
	}
	else if(current->type == WEAPON_SHOTGUN)
	{
		curvature = gameclient.tuning.shotgun_curvature;
		speed = gameclient.tuning.shotgun_speed;
	}
	else if(current->type == WEAPON_GUN)
	{
		curvature = gameclient.tuning.gun_curvature;
		speed = gameclient.tuning.gun_speed;
	}

	float ct = (client_prevtick()-current->start_tick)/(float)SERVER_TICK_SPEED + client_ticktime();
	if(ct < 0)
		return; // projectile havn't been shot yet
		
	vec2 startpos(current->x, current->y);
	vec2 startvel(current->vx/100.0f, current->vy/100.0f);
	vec2 pos = calc_pos(startpos, startvel, curvature, speed, ct);
	vec2 prevpos = calc_pos(startpos, startvel, curvature, speed, ct-0.001f);


	gfx_texture_set(data->images[IMAGE_GAME].id);
	gfx_quads_begin();
	
	select_sprite(data->weapons.id[clamp(current->type, 0, NUM_WEAPONS-1)].sprite_proj);
	vec2 vel = pos-prevpos;
	//vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick());
	

	// add particle for this projectile
	if(current->type == WEAPON_GRENADE)
	{
		gameclient.effects->smoketrail(pos, vel*-1);
		gameclient.flow->add(pos, vel*1000*client_frametime(), 10.0f);
		gfx_quads_setrotation(client_localtime()*pi*2*2 + itemid);
	}
	else
	{
		gameclient.effects->bullettrail(pos);
		gameclient.flow->add(pos, vel*1000*client_frametime(), 10.0f);

		if(length(vel) > 0.00001f)
			gfx_quads_setrotation(get_angle(vel));
		else
			gfx_quads_setrotation(0);

	}

	gfx_quads_draw(pos.x, pos.y, 32, 32);

	///--- Added by Tigra
	// Draw shadows of grenades
	bool local_player_in_game = 
		gameclient.clients[gameclient.snap.local_cid].team != -1;

	if(config.cl_antiping && current->type == WEAPON_GRENADE && local_player_in_game)
	{
		// Calculate average prediction offset, because client_predtick() gets varial values :(((
		// Must be there is a normal way to realize it, but I'm too lazy to find it. ^)
		if (gameclient.average_prediction_offset == -1)
		{
			int offset = client_predtick() - client_tick();
			gameclient.prediction_offset_summ += offset;
			gameclient.prediction_offset_count++;

			if (gameclient.prediction_offset_count >= 100)
			{
				gameclient.average_prediction_offset = 
					round((float)gameclient.prediction_offset_summ / gameclient.prediction_offset_count);
			}
		}		

		// Draw shadow only if grenade directed to local player
		int local_cid = gameclient.snap.local_cid;
		NETOBJ_CHARACTER& cur_char = gameclient.snap.characters[local_cid].cur;
		NETOBJ_CHARACTER& prev_char = gameclient.snap.characters[local_cid].prev;
		vec2 server_pos = mix(vec2(prev_char.x, prev_char.y), vec2(cur_char.x, cur_char.y), client_intratick());

		float d1 = distance(pos, server_pos);
		float d2 = distance(prevpos, server_pos);
		if (d1 < 0) d1 *= -1;
		if (d2 < 0) d2 *= -1;
		bool grenade_directed_to_local_player = d1 < d2;

		if (gameclient.average_prediction_offset != -1 && grenade_directed_to_local_player)
		{
			int predicted_tick = client_prevtick() + gameclient.average_prediction_offset;
			float predicted_ct = (predicted_tick - current->start_tick)/(float)SERVER_TICK_SPEED + client_ticktime();
		
			if (predicted_ct >= 0)
			{
				int shadow_type = WEAPON_GUN; // Pistol bullet sprite is used for marker of shadow. TODO: use something custom.
				select_sprite(data->weapons.id[clamp(shadow_type, 0, NUM_WEAPONS-1)].sprite_proj);

				vec2 predicted_pos = calc_pos(startpos, startvel, curvature, speed, predicted_ct);
				gfx_quads_draw(predicted_pos.x, predicted_pos.y, 32, 32);
			}
		}
	}
	///---

	gfx_quads_setrotation(0);
	gfx_quads_end();
}
Ejemplo n.º 19
0
static cv::Point th_angular_histo(cv::Mat *pic, cv::Mat *pic_th, int start_x, int end_x, int start_y, int end_y, int th, double th_histo, int max_region_hole, int min_region_size){
	cv::Point pos(0,0);


	if(start_x<0) start_x=0;
	if(start_y<0) start_y=0;
	if(end_x>pic->cols) end_x=pic->cols;
	if(end_y>pic->rows) end_y=pic->rows;

	int max_l=0;
	int max_lb=0;
	int max_b=0;
	int max_br=0;

	int min_l, min_lb, min_b, min_br;
	int pos_l, pos_lb, pos_b, pos_br;


	int hist_l[DEF_SIZE];
	int hist_lb[DEF_SIZE];
	int hist_b[DEF_SIZE];
	int hist_br[DEF_SIZE];

	for(int i=0; i<DEF_SIZE; i++){
		hist_l[i]=0;
		hist_lb[i]=0;
		hist_b[i]=0;
		hist_br[i]=0;
	}

	int idx_lb=0;
	int idx_br=0;
	for(int i=start_x; i<end_x; i++)
		for(int j=start_y; j<end_y; j++){

			if(pic->data[(pic->cols*j)+i]<th){

				pic_th->data[(pic->cols*j)+i]=255;

				idx_lb=(pic->cols/2)+(i-(pic->cols/2))+(j);
				idx_br=(pic->cols/2)+(i-(pic->cols/2))+(pic->rows-j);

				if(j>=0 && j<DEF_SIZE && i>=0 && i<DEF_SIZE && idx_lb>=0 && idx_lb<DEF_SIZE && idx_br>=0 && idx_br<DEF_SIZE){

				if(++hist_l[j]>max_l) max_l=hist_l[j];

				if(++hist_b[i]>max_b) max_b=hist_b[i];


				if(++hist_lb[idx_lb]>max_lb) max_lb=hist_lb[idx_lb];

				if(++hist_br[idx_br]>max_br) max_br=hist_br[idx_br];
			
				}
			}

		}

	


	min_l=max_l-floor(max_l*th_histo);
	min_lb=max_lb-floor(max_lb*th_histo);
	min_b=max_b-floor(max_b*th_histo);
	min_br=max_br-floor(max_br*th_histo);

	pos_l=calc_pos(hist_l, min_l, max_region_hole, min_region_size, pic->rows);
	pos_lb=calc_pos(hist_lb, min_lb, max_region_hole, min_region_size, pic->cols+pic->rows);
	pos_b=calc_pos(hist_b, min_b, max_region_hole, min_region_size, pic->cols);
	pos_br=calc_pos(hist_br, min_br, max_region_hole, min_region_size, pic->cols+pic->rows);


	/*
std::cout<<"min_l: "<<min_l<<" min_lb: "<<min_lb<<std::endl;	
std::cout<<"min_b: "<<min_b<<" min_br: "<<min_br<<std::endl;	

std::cout<<"l: "<<pos_l<<"    lb: "<<pos_lb<<std::endl;
std::cout<<"b: "<<pos_b<<"    br: "<<pos_br<<std::endl;
*/
	
	if(pos_l>0 && pos_lb>0 && pos_b>0 && pos_br>0){
		pos.x=floor( ((pos_b+ (floor( (((pos_br+pic->rows)-pos_lb)/2) +0.5) +pos_lb-pic->rows) )/2)+0.5);
		pos.y=floor( ((pos_l+ (pic->rows - floor( (((pos_br+pic->rows)-pos_lb)/2) +0.5)) )/2)+0.5);
	}else if(pos_l>0 && pos_b>0){
		pos.x=pos_b;
		pos.y=pos_l;
	}else if(pos_lb>0 && pos_br>0){
		pos.x=floor( (((pos_br+pic->rows)-pos_lb)/2) +0.5) +pos_lb-pic->rows ;
		pos.y=pic->rows - floor( (((pos_br+pic->rows)-pos_lb)/2) +0.5);
	}

	if(pos.x<0) pos.x=0;
	if(pos.y<0) pos.y=0;
	if(pos.x>=pic->cols) pos.x=0;
	if(pos.y>=pic->rows) pos.y=0;

	
	/*
	std::cout<<pos.x<<";"<<pos.y<<std::endl;
	imshow("th",*pic_th);
	cv::ellipse(*pic, cv::RotatedRect(pos, cv::Size2f(5,5),0), CV_RGB(255,255,255));
	imshow("angular",*pic);
	*/

	return pos;

}
Ejemplo n.º 20
0
void OSD::setPanel(uint8_t st_col, uint8_t st_row){
  col = st_col & 0x7f; // col,row нужны для отработки перевода строки с сохранением колонки
  row = st_row & 0x3f; // в старших битах флаги, размер экрана все равно мелкий

  calc_pos();
}