void FastDetector::detect( Frame* frame, const ImgPyr& img_pyr, const double detection_threshold, Features& fts) { Corners corners(grid_n_cols_*grid_n_rows_, Corner(0,0,detection_threshold,0,0.0f)); for(int L=0; L<n_pyr_levels_; ++L) { const int scale = (1<<L); vector<fast::fast_xy> fast_corners; #if __SSE2__ fast::fast_corner_detect_10_sse2( (fast::fast_byte*) img_pyr[L].data, img_pyr[L].cols, img_pyr[L].rows, img_pyr[L].cols, 20, fast_corners); #elif HAVE_FAST_NEON fast::fast_corner_detect_9_neon( (fast::fast_byte*) img_pyr[L].data, img_pyr[L].cols, img_pyr[L].rows, img_pyr[L].cols, 20, fast_corners); #else fast::fast_corner_detect_10( (fast::fast_byte*) img_pyr[L].data, img_pyr[L].cols, img_pyr[L].rows, img_pyr[L].cols, 20, fast_corners); #endif vector<int> scores, nm_corners; fast::fast_corner_score_10((fast::fast_byte*) img_pyr[L].data, img_pyr[L].cols, fast_corners, 20, scores); fast::fast_nonmax_3x3(fast_corners, scores, nm_corners); for(auto it=nm_corners.begin(), ite=nm_corners.end(); it!=ite; ++it) { fast::fast_xy& xy = fast_corners.at(*it); const int k = static_cast<int>((xy.y*scale)/cell_size_)*grid_n_cols_ + static_cast<int>((xy.x*scale)/cell_size_); if(grid_occupancy_[k]) continue; const float score = vk::shiTomasiScore(img_pyr[L], xy.x, xy.y); if(score > corners.at(k).score) corners.at(k) = Corner(xy.x*scale, xy.y*scale, score, L, 0.0f); } } // Create feature for every corner that has high enough corner score std::for_each(corners.begin(), corners.end(), [&](Corner& c) { if(c.score > detection_threshold) fts.push_back(new Feature(frame, Vector2d(c.x, c.y), c.level)); }); resetGrid(); }
ZIntCuboidFace::Corner ZIntCuboidFace::getCorner(int index) const { switch (index) { case 0: return getFirstCorner(); case 1: return Corner(getUpperBound(0), getLowerBound(1)); case 2: return Corner(getLowerBound(0), getUpperBound(1)); case 3: return getLastCorner(); } return Corner(0, 0); }
void AeroControlBase::GetRoundRectPath(GraphicsPath *pPath, Rect r, int dia) const { // diameter can't exceed width or height if(dia > r.Width) dia = r.Width; if(dia > r.Height) dia = r.Height; // define a corner Rect Corner(r.X, r.Y, dia, dia); // begin path pPath->Reset(); pPath->StartFigure(); // top left pPath->AddArc(Corner, 180, 90); // top right Corner.X += (r.Width - dia - 1); pPath->AddArc(Corner, 270, 90); // bottom right Corner.Y += (r.Height - dia - 1); pPath->AddArc(Corner, 0, 90); // bottom left Corner.X -= (r.Width - dia - 1); pPath->AddArc(Corner, 90, 90); // end path pPath->CloseFigure(); }
const void Frustum::GetCorners( float3* out_points) const { for( int i = 0; i < 8; ++i) { out_points[i] = Corner(i); } }
void R3Box:: Draw() const { // Get box corner points R3Point corners[8]; corners[0] = Corner(0, 0, 0); corners[1] = Corner(0, 0, 1); corners[2] = Corner(0, 1, 1); corners[3] = Corner(0, 1, 0); corners[4] = Corner(1, 0, 0); corners[5] = Corner(1, 0, 1); corners[6] = Corner(1, 1, 1); corners[7] = Corner(1, 1, 0); // Get normals, texture coordinates, etc. static GLdouble normals[6][3] = { { -1.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, -1.0 }, { 0.0, 0.0, 1.0 } }; static GLdouble texcoords[4][2] = { { 0.0, 0.0 }, { 1.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 1.0 } }; static int surface_paths[6][4] = { /* { 3, 0, 1, 2 }, { 4, 7, 6, 5 }, { 0, 4, 5, 1 }, { 7, 3, 2, 6 }, { 3, 7, 4, 0 }, { 1, 5, 6, 2 }*/ { 0, 1, 2, 3 }, { 5, 4, 7, 6 }, { 0, 4, 5, 1 }, { 7, 3, 2, 6 }, { 4, 0, 3, 7 }, { 1, 5, 6, 2 } }; // Draw box glBegin(GL_QUADS); for (int i = 0; i < 6; i++) { glNormal3d(normals[i][0], normals[i][1], normals[i][2]); for (int j = 0; j < 4; j++) { const R3Point& p = corners[surface_paths[i][j]]; glTexCoord2d(texcoords[j][0], texcoords[j][1]); glVertex3d(p[0], p[1], p[2]); } } glEnd(); }
void AABox::SupportMapping( const CVector3& v, CVector3& result ) const { //Vector3.Dot(ref this.corners[0], ref v, out num3); float num3 = v.Dot( Corner(0) ); int index = 0; for (int i = 1; i < 8; i++) { float num2 = v.Dot( Corner(i) ); if (num2 > num3) { index = i; num3 = num2; } } result = Corner(index); }
Grid::Grid (int s) : size (s) { for (int i=0; i<tile_count(size); i++) tiles.push_back(Tile(i, i<12 ? 5 : 6)); for (int i=0; i<corner_count(size); i++) corners.push_back(Corner(i)); for (int i=0; i<edge_count(size); i++) edges.push_back(Edge(i)); }
void R3Rectangle:: Draw(const R3DrawFlags draw_flags) const { // Check if box is empty if (IsEmpty()) return; /* Get texture coordinates */ static R2Point texcoords[4] = { R2Point(0.0, 0.0), R2Point(1.0, 0.0), R2Point(1.0, 1.0), R2Point(0.0, 1.0) }; /* Get box corner points */ R3Point corners[4]; corners[0] = Corner(RN_NN_QUADRANT); corners[1] = Corner(RN_PN_QUADRANT); corners[2] = Corner(RN_PP_QUADRANT); corners[3] = Corner(RN_NP_QUADRANT); // Draw surface if (draw_flags[R3_SURFACES_DRAW_FLAG]) { if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) R3LoadNormal(Normal()); R3BeginPolygon(); for (int j = 0; j < 4; j++) { if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) R3LoadTextureCoords(texcoords[j]); R3LoadPoint(corners[j]); } R3EndPolygon(); } // Draw edges if (draw_flags[R3_EDGES_DRAW_FLAG]) { R3BeginLoop(); for (int i = 0; i < 4; i++) R3LoadPoint(corners[i]); R3EndLoop(); } }
ZIntCuboidFaceArray ZIntCuboidFace::cropBy(const ZIntCuboidFace &face) const { ZIntCuboidFaceArray faceArray; if (hasOverlap(face)) { if (isWithin(face)) { return faceArray; } else { ZIntCuboidFace subface(getAxis(), isNormalPositive()); subface.setZ(getPlanePosition()); subface.set(getFirstCorner(), Corner(getUpperBound(0), face.getLowerBound(1) - 1)); faceArray.appendValid(subface); subface.set(Corner(getLowerBound(0), imax2(getLowerBound(1), face.getLowerBound(1))), Corner(face.getLowerBound(0) - 1, getUpperBound(1))); faceArray.appendValid(subface); subface.set(Corner(face.getUpperBound(0) + 1, imax2(getLowerBound(1), face.getLowerBound(1))), getLastCorner()); faceArray.appendValid(subface); subface.set(Corner(imax2(getLowerBound(0), face.getLowerBound(0)), face.getUpperBound(1) + 1), Corner(imin2(getUpperBound(0), face.getUpperBound(0)), getUpperBound(1))); faceArray.appendValid(subface); } #if 0 else if (face.isWithin(*this)) { ZIntCuboidFace subface(getAxis(), isNormalPositive()); secondCorner.set(getUpperBound(0), face.getLowerBound(1)); subface.set(getFirstCorner(), secondCorner); faceArray.appendValid(subface); subface.set(Corner(getLowerBound(0), face.getLowerBound(1)), face.getCorner(2)); faceArray.appendValid(subface); subface.set(Corner(getLowerBound(0), face.getUpperBound(1)), getLastCorner()); faceArray.appendValid(subface); } else { } #endif } else {
void Draw::World(GLvoid) { dotsRemaining = 0; if(levelCom) LoadWorld(); glPushMatrix(); glTranslatef(-50.0f,0.0f,-50.0f); for(unsigned int i = 0; i < worldLayout.size(); i++) { switch(worldLayout[i]) { case 'T': Top(i); break; case 'B': Bottom(i); break; case 'L': Left(i); break; case 'R': Right(i); break; case 'U': case 'D': Corner(i); break; case 'Z': Dots(i); break; case 'X': SpawnLoc.xp = lctn[i].x; SpawnLoc.zp = lctn[i].t; SpawnLoc.yp = 1.1f; break; case 'G': //GZone(i); break; case 'Y': //Teleport(i); break; case 'W': //TPWalls(i); break; case 'S': Start(i); break; } } if(levelStr) Ghosts(); glPopMatrix(); }
void R3Box:: Transform (const R3Transformation& transformation) { // Do not transform empty box if (IsEmpty()) return; // Transform box ??? R3Box tmp = R3null_box; for (RNOctant octant = 0; octant < RN_NUM_OCTANTS; octant++) { R3Point corner(Corner(octant)); corner.Transform(transformation); tmp.Union(corner); } *this = tmp; }
void R3Box:: Transform (const R3Matrix& matrix) { // Do not transform empty box if (IsEmpty()) return; // Transform box R3Box tmp = R3null_box; tmp.Union(matrix * Corner(0,0,0)); tmp.Union(matrix * Corner(0,0,1)); tmp.Union(matrix * Corner(0,1,0)); tmp.Union(matrix * Corner(0,1,1)); tmp.Union(matrix * Corner(1,0,0)); tmp.Union(matrix * Corner(1,0,1)); tmp.Union(matrix * Corner(1,1,0)); tmp.Union(matrix * Corner(1,1,1)); *this = tmp; }
void InternalToolBox::restore(const KConfigGroup &containmentGroup) { KConfigGroup group = KConfigGroup(&containmentGroup, "ToolBox"); if (!group.hasKey("corner")) { return; } m_userMoved = true; setCorner(Corner(group.readEntry("corner", int(corner())))); const int offset = group.readEntry("offset", 0); const int w = boundingRect().width(); const int h = boundingRect().height(); const int maxW = m_containment ? m_containment->geometry().width() - w : offset; const int maxH = m_containment ? m_containment->geometry().height() - h : offset; switch (corner()) { case InternalToolBox::TopLeft: setPos(0, 0); break; case InternalToolBox::Top: setPos(qMin(offset, maxW), 0); break; case InternalToolBox::TopRight: setPos(m_containment->size().width() - boundingRect().width(), 0); break; case InternalToolBox::Right: setPos(m_containment->size().width() - boundingRect().width(), qMin(offset, maxH)); break; case InternalToolBox::BottomRight: setPos(m_containment->size().width() - boundingRect().width(), m_containment->size().height() - boundingRect().height()); break; case InternalToolBox::Bottom: setPos(qMin(offset, maxW), m_containment->size().height() - boundingRect().height()); break; case InternalToolBox::BottomLeft: setPos(0, m_containment->size().height() - boundingRect().height()); break; case InternalToolBox::Left: setPos(0, qMin(offset, maxH)); break; } //kDebug() << "marked as user moved" << pos() // << (m_containment->containmentType() == Containment::PanelContainment); }
BOOL GDIPluseExt::MakeRoundRectPath(GraphicsPath* pPath,CRect rect, int radius) { pPath->StartFigure(); REAL width = rect.Width() - 1.5f; REAL height = rect.Height() - 1.0f; Rect r((INT)rect.left,(INT) rect.top, (INT)width, (INT)height); int dia = radius; if(dia > r.Width) dia = r.Width; if(dia > r.Height) dia = r.Height; // define a corner Rect Corner(r.X, r.Y, dia, dia); // top left pPath->AddArc(Corner, 180, 90); if(dia == 20) { Corner.Width += 1; Corner.Height += 1; r.Width -=1; r.Height -= 1; } //top right Corner.X += (r.Width - dia - 1); pPath->AddArc(Corner, 270, 90); // bottom right Corner.Y += (r.Height - dia - 1); pPath->AddArc(Corner, 0, 90); // bottom left Corner.X -= (r.Width - dia - 1); pPath->AddArc(Corner, 90, 90); pPath->CloseFigure(); return TRUE; }
/* Calculates the spread value. * The value is determined according to friction and the position of the * neighbors. If the neighbors are corner neighbors, the average * friction is multiplied with the diagonal, else with the side. * Returns the spread value. */ static REAL8 CalcSpreadValue( INT4 *id, /* write-only id */ const MAP_REAL8 *outCost, /* output costs */ const MAP_INT4 *outId, /* id map from spread */ const MAP_REAL8 *friction, /* friction map */ int r, /* row current cell */ int c, /* column curr. cell */ REAL8 f) /* friction value (r, c) */ { REAL8 costs, costVal, fricNxt, minCosts; int i, rNext, cNext; INT4 newId = 0; /* id spread point of min. cost */ minCosts = REAL8_MAX; /* minimum costs until now */ FOR_ALL_LDD_NBS(i) { rNext = RNeighbor(r, i); cNext = CNeighbor(c, i); if(outCost->Get(&costVal, rNext, cNext, outCost) && (friction->Get(&fricNxt, rNext, cNext, friction))) { costs = (f + fricNxt) / 2; costs *= (Corner(i) == FALSE) SCALE; costs += costVal; if(costs < minCosts) { /* cheapest path from neighbor to r,c */ minCosts = costs; outId->Get(&newId, rNext, cNext, outId); *id = newId; POSTCOND(*id != 0); } } } *id = newId; /* id from cheapest neighbor */ return minCosts; /* minimum costs to get to r, c */ }
/* Determines all lowest neighbors and gives them output. * All lowest neighbors from current cell are put at the beginning of * the list (depth-first) and the stream is added to their output value. * Returns list if successful, NULL when memory allocation failed. */ static NODE *DoNeighbors( MAP_REAL8 * out, /* read-write output map */ NODE *list, /* read-write list */ const MAP_REAL8 * dem, /* dem map */ const MAP_REAL8 * points, /* points map */ int r, /* current cell row */ int c, /* current cell column */ REAL8 drainVal) /* value to drain down */ { NODE *list2 = NULL; /* list of lowest neighbors */ REAL8 dropMax = 0; /* maximal drop value */ REAL8 dropVal = 0; /* maximal drop value */ int i, nrPaths = 0; /* nr of outgoing paths */ REAL8 demVal, newDem, outVal, pntVal; /* dem value * and output value of old and new cell and the * point value of both to check on MV. */ PRECOND(dem->GetGetTest(dem) == GET_MV_TEST); PRECOND(points->GetGetTest(points) == GET_MV_TEST); PRECOND(out->GetGetTest(out) == GET_MV_TEST); PRECOND(dem->Get(&demVal, r, c, dem)); PRECOND(out->Get(&outVal, r, c, out)); dem->Get(&demVal, r, c, dem); /* height original cell */ out->Get(&outVal, r, c, out); /* output original cell */ for(i = 1; i <= NR_LDD_DIR; i++) { /* check all neighbors */ int rNext = RNeighbor(r, i); int cNext = CNeighbor(c, i); if(dem->Get(&newDem, rNext, cNext, dem) && /* no MV */ points->Get(&pntVal, rNext, cNext, points) &&/* no MV */ (i != LDD_PIT) && /* skip cell itself */ (0 < (demVal - newDem))) /* lower than current cell */ { REAL8 dist = (Corner(i) == FALSE) SCALE; dropVal = (demVal - newDem) / dist; if(dropMax <= dropVal) { NODE *tmp; if(dropMax < dropVal) { /* all previous found neighbors * were not the lowest -> reset. */ list2 = FreeList(list2); POSTCOND(list2 == NULL); nrPaths = 0; dropMax = dropVal; } nrPaths++; tmp = LinkToList(list2, rNext, cNext); if(tmp == NULL) { FreeList(list2); FreeList(list); return NULL; } list2 = tmp; } } } drainVal /= nrPaths; /* divide between steepest paths */ while(list2 != NULL) { PRECOND(out->Get(&outVal, list2->rowNr, list2->colNr, out)); out->Get(&outVal, list2->rowNr, list2->colNr, out); outVal += drainVal; out->Put(outVal, list2->rowNr, list2->colNr, out); list = LinkChkReal(list, list2->rowNr, list2->colNr, drainVal); if(list == NULL) { FreeList(list2); return NULL; } list2 = RemFromList(list2); } POSTCOND(list != NULL); /* result HasLowerNeighbor was TRUE */ return list; }
int CBwfind::findfirst(int tb[][8] , int &step, int &flag, int cut) { int value=0,max=-100000,min=100000,k=0,i,j; int temp[8][8]; if(step==depth){ return valuefirst(tb); } for(i=0;i<8;i++)for(j=0;j<8;j++) temp[i][j]=tb[i][j]; for(i=0;i<8;i++)for(j=0;j<8;j++){ if(judge(tb,i,j,flag)){ int ii,jj; value=0; k=1;//存在合理的步子 newboard(tb,i,j,flag); flag=-flag; step++; if(-flag==ComChoice){ LineSense(tb,i,j,value); Corner(tb,i,j,value); value+=findfirst(tb,step,flag,max); } if(-flag==ManChoice){ Corner(tb,i,j,value); LineSense(tb,i,j,value); value+=findfirst(tb,step,flag,min); } step--; flag=-flag; //恢复棋盘 for(ii=0;ii<8;ii++) for(jj=0;jj<8;jj++) tb[ii][jj]=temp[ii][jj]; if(flag-ManChoice==0&&value<cut) return value; if(flag-ComChoice==0&&value>cut) return value; if(flag-ManChoice==0){ if(value<min){ min=value; } } if(flag-ComChoice==0){ if(value>max){ max=value; if(step==0){ stepx=i; stepy=j; } } } }//if }//for //当前没有步可走 if(k==0){ flag=-flag; if(search(tb,flag)){ value=findfirst(tb,step,flag,cut); flag=-flag; return value; } else{ flag=-flag; return valuefirst(tb); } } //存在合理步 else{ if(flag-ManChoice==0) return min; else if(flag-ComChoice==0){ //if return max; }//if }//else }
void R3OrientedBox:: Draw(const R3DrawFlags draw_flags) const { // Check if box is empty if (IsEmpty()) return; static R2Point texcoords[4] = { R2Point(0.0, 0.0), R2Point(1.0, 0.0), R2Point(1.0, 1.0), R2Point(0.0, 1.0) }; static int surface_paths[6][4] = { { 3, 0, 1, 2 }, { 4, 7, 6, 5 }, { 0, 4, 5, 1 }, { 7, 3, 2, 6 }, { 3, 7, 4, 0 }, { 1, 5, 6, 2 } }; static int outline_path[16] = { 0, 1, 2, 3, 0, 4, 5, 6, 7, 4, 5, 1, 2, 6, 7, 3 }; /* Get box corner points */ R3Point corners[8]; corners[0] = Corner(RN_NNN_OCTANT); corners[1] = Corner(RN_NNP_OCTANT); corners[2] = Corner(RN_NPP_OCTANT); corners[3] = Corner(RN_NPN_OCTANT); corners[4] = Corner(RN_PNN_OCTANT); corners[5] = Corner(RN_PNP_OCTANT); corners[6] = Corner(RN_PPP_OCTANT); corners[7] = Corner(RN_PPN_OCTANT); // Draw surface if (draw_flags[R3_SURFACES_DRAW_FLAG]) { for (int i = 0; i < 6; i++) { R3BeginPolygon(); if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) { RNScalar sign = (i < 3) ? 1.0 : -1.0; R3LoadNormal(sign * Axis(i%3)); } for (int j = 0; j < 4; j++) { if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) R3LoadTextureCoords(texcoords[j]); R3LoadPoint(corners[surface_paths[i][j]]); } R3EndPolygon(); } } // Draw edges if (draw_flags[R3_EDGES_DRAW_FLAG]) { R3BeginLine(); for (int i = 0; i < 16; i++) R3LoadPoint(corners[outline_path[i]]); R3EndLine(); } }