void RgnPixelDrawer::RectToImpl(int to_x, int to_y) { Rect rct(curX, curY, to_x, to_y); DrwFunctor drw_fnr = bb::bind(&RgnPixelDrawer::RectToImplRect, this, _1); DrawWithFunctor(rct, drw_fnr); }
static OSStatus qt_mac_get_rgn_rect(UInt16 msg, RgnHandle, const Rect *rect, void *reg) { if(msg == kQDRegionToRectsMsgParse) { QRect rct(rect->left, rect->top, (rect->right - rect->left), (rect->bottom - rect->top)); if(!rct.isEmpty()) *((QRegion *)reg) += rct; } return noErr; }
void CKSPlugInGUIPane::SetWidth(tuint32 uiNew) { mpPane->SetSize(ge::SSize(uiNew, 124)); GetWindow()->SetSize(ge::SSize(uiNew, 124)); mpToolbar->SetWidth(uiNew); ge::SRect rct(ge::SPos(0, 0), ge::SSize(uiNew, 124)); mpPane->Redraw(rct); }
DLLEXP void set_pixel(int x,int y,DWORD clr) { g_memdc.SetPixel(x,y,clr); g_buf_clr[y*g_scn_width+x]=clr; if (g_pdlg_show!=NULL) { CRect rct(x,y,x+1,y+1); g_pdlg_show->InvalidateRect(&rct); } }
void graph::print_paths(vector<vector<adj*>> & paths) { int i(1); for( vector<adj*> & path : paths ) { cout << i << " :" << endl;//These can be sorted by total cost,number of reactions, change in H,S,G etc. USING A TREE. int j(1); for(adj * step : path ) { cout << " "<< j << ". "; if( step->parent->plus ) { vector<adj>::iterator rct(step->parent->adjs.begin()); for(; rct != step->parent->adjs.end()-1; rct++ ) cout << rct->toself->name << " + "; cout << rct->toself->name; } else cout << step->parent->name; cout << " --> ";//Used catalyst can be reported here: a good way to do that : A + B --Cat--> C + D if( step->toself->plus ) { vector<adj>::iterator rct(step->toself->adjs.begin()); for(; rct != step->toself->adjs.end()-1; rct++ ) cout << rct->toself->name << " + "; cout << rct->toself->name; } else cout << step->toself->name; cout << " Change in Enthalpy: " << step->H; //many other things such as change in S,G, cost etc. can be reported here. cout << endl; j++; } i++; cout << endl; // The total change in H,S,G total cost etc. can be reported here. } }
void CoverSvc::AddRect(const DRect& user_rct) { DRect drct(CR::UserToDevice(cont, user_rct)); Rect rct( (int)std::floor(drct.lft), (int)std::floor(drct.top), (int)std::ceil(drct.rgt), (int)std::ceil(drct.btm) ); // на всякий случай увеличим rct = EnlargeRect(rct, Point(1, 1)); // :TODO: переделать используя ReDivide() trkLay.queue_draw_area(rct.lft, rct.top, rct.Width(), rct.Height()); }
void CVST2KSPIGUI::MakeWindow(void* p) { if (mpVSTEffect == NULL) { mpVSTEffect = dynamic_cast<CVST2KSPIPlugIn*>(GetPlugIn())->GetEffect(); } try { PreCreate(); // Create the window mpWindow = ge::IWindow::Create(); // Tell the window what context it's in mpWindow->SetContext(mpContext); #ifdef WIN32 mhWndParent = (HWND)p; mpVSTEffect->dispatcher(mpVSTEffect, effEditOpen, 0, 0, p, 0.0); #endif #ifdef _Mac /*void**/ mhWndParent = p; mpVSTEffect->dispatcher(mpVSTEffect, effEditOpen, 0, 0, p, 0.0); #endif tuint32 iSizeX; tuint32 iSizeY; GetSize(&iSizeX, &iSizeY); ge::SRect rct(0, 0, iSizeX, iSizeY); // mpWindow->MakeWindow(mhWndParent, &rct, false); Initialize(); // Make the window visible // mpWindow->ShowWindow(); // mpWindow->InstallKeyboardHook(); // mpWindow->AcquireKeyboardInput(); mbWindowMade = true; } catch(IException* pException) { const tchar* psz = pException->GetFullDescription(); // DoMsgBox(psz); pException->Destroy(); } catch(...) { // DoMsgBox("Unknown Exception"); } }
void DrawGrabFrame(RGBA::Drawer& drw, const Rect& plc_rct) { Rect rct(plc_rct); rct.lft -= 1; // рисуем вокруг rct.top -= 1; const int frame_space = 1; // отступ от объекта rct.lft -= frame_space; rct.top -= frame_space; rct.btm += frame_space; rct.rgt += frame_space; const int frame_clr = 0x50ff7bff; // - зеленые цвета с одним оттенком = 135 const int square_clr = 0x1da93fff; // drw.SetForegroundColor(frame_clr); // 1 рамка drw.MoveTo(rct.lft, rct.top); drw.FrameRectTo(rct.rgt, rct.btm); // 2 "ручки"-прямоугольники Point sz = rct.Size(); int dot_tbl[9][2] = { {0, 0}, {sz.x/2, 0}, {sz.x, 0}, {0, sz.y/2}, {sz.x/2, sz.y/2}, {sz.x, sz.y/2}, {0, sz.y}, {sz.x/2, sz.y}, {sz.x, sz.y} }; for( int x=0; x<3; x++ ) for( int y=0; y<3; y++ ) { if( x == 1 && y == 1 ) // середину не рисуем continue; int c_x = rct.lft + dot_tbl[x+y*3][0]; int c_y = rct.top + dot_tbl[x+y*3][1]; const int E_SZ = 2; // половина стороны квадратика drw.SetForegroundColor(frame_clr); drw.MoveTo(c_x-E_SZ, c_y-E_SZ); // прибавляем 1 чтобы рисовалось симметрично drw.RectTo(c_x+E_SZ+1, c_y+E_SZ+1); const int I_SZ = 1; drw.SetForegroundColor(square_clr); drw.MoveTo(c_x-I_SZ, c_y-I_SZ); drw.RectTo(c_x+I_SZ+1, c_y+I_SZ+1); } }
void Scene::renderGameStatistics() { // Show intro if( m_fTimer < 3.0f ) { scene->renderFont( 255, 0, 255, 0, 3.0f, GAME_WIDTH / 2.0f, 30.0f, HGETEXT_CENTER, "-=SURVIVAL=-" ); } // Show statistics std::string atp( "attempts: " ); atp += std::to_string( attempts ); renderFont( 255, 128, 128, 128, 1.0f, GAME_WIDTH - 140.0f, 10.0f, HGETEXT_LEFT, atp ); std::string str( "health: "); int health = static_cast<int>( objects->getTank( )->getHealth( ) * 100 ); str += std::to_string( health ); renderFont( 255, 128, 128, 128, 1.0f, GAME_WIDTH - 140.0f, 40.0f, HGETEXT_LEFT, str ); std::string timer( "timer: "); timer += std::to_string( static_cast<int>(SURVIVAL_TIME) - static_cast<int>(m_fTimer) ); timer += "s"; renderFont( 255, 128, 128, 128, 1.0f, GAME_WIDTH - 140.0f, 70.0f, HGETEXT_LEFT, timer ); std::string bst( "beasts: ") ; bst += std::to_string( objects->getDeadBeastQuantity( ) ); renderFont( 255, 128, 128, 128, 1.0f, 10.0f, 10.0f, HGETEXT_LEFT, bst ); std::string dmn( "daemons: "); dmn += std::to_string( objects->getDeadDaemonQuantity( ) ); renderFont( 255, 128, 128, 128, 1.0f, 10.0f, 40.0f, HGETEXT_LEFT, dmn ); std::string rpt( "reptiles: "); rpt += std::to_string( objects->getDeadReptileQuantity( ) ); renderFont( 255, 128, 128, 128, 1.0f, 10.0f, 70.0f, HGETEXT_LEFT, rpt ); std::string blt( "bullets: "); blt += std::to_string( Weapon::getBulletsQuantity( ) ); renderFont( 255, 128, 128, 128, 1.0f, 10.0f, GAME_HEIGHT - 90.0f, HGETEXT_LEFT, blt ); std::string shl( "shells: "); shl += std::to_string( Weapon::getShellsQuantity( ) ); renderFont( 255, 128, 128, 128, 1.0f, 10.0f, GAME_HEIGHT - 60.0f, HGETEXT_LEFT, shl ); std::string rct( "rockets: "); rct += std::to_string( Weapon::getRocketsQuantity( ) ); renderFont( 255, 128, 128, 128, 1.0f, 10.0f, GAME_HEIGHT - 30.0f, HGETEXT_LEFT, rct ); }
int main(){ // For testing use 1:1 LUT std::vector<double> eGammaECalScaleFactors(32, 1.0); std::vector<double> eGammaHCalScaleFactors(32, 1.0); std::vector<double> jetMETECalScaleFactors(32, 1.0); std::vector<double> jetMETHCalScaleFactors(32, 1.0); std::vector<double> c,d,e,f,g,h; L1RCTParameters* rctParameters = new L1RCTParameters(1.0, // eGammaLSB 1.0, // jetMETLSB 3.0, // eMinForFGCut 40.0, // eMaxForFGCut 0.5, // hOeCut 1.0, // eMinForHoECut 50.0, // eMaxForHoECut 1.0, // hMinForHoECut 2.0, // eActivityCut 3.0, // hActivityCut 3, // eicIsolationThreshold 3, // jscQuietThresholdBarrel 3, // jscQuietThresholdEndcap false, // noiseVetoHB false, // noiseVetoHEplus false, // noiseVetoHEminus false, // use Lindsey eGammaECalScaleFactors, eGammaHCalScaleFactors, jetMETECalScaleFactors, jetMETHCalScaleFactors, c, d, e, f, g, h ); L1RCTLookupTables* lut = new L1RCTLookupTables(); lut->setRCTParameters(rctParameters); // transcoder and etScale are not used L1RCT rct(lut); rct.randomInput(); //rct.print(); rct.processEvent(); rct.printJSC(); }
void CRectangle::NormalizeData() { CPoint ptLT; CPoint ptRB; ptLT.x = (int)m_ptary[0].X; ptLT.y = (int)m_ptary[0].Y; ptRB.x = (int)m_ptary[1].X; ptRB.y = (int)m_ptary[1].Y; CRect rct(ptLT,ptRB); rct.NormalizeRect(); if(RS_SQUARE == m_nRStyle) { float fWidth = (float)min(rct.Width(),rct.Height()); float fleft = 0,ftop = 0; if(m_ptary[0].X <= m_ptary[1].X) { fleft = m_ptary[0].X; } else { fleft = m_ptary[0].X - fWidth; } if(m_ptary[0].Y <= m_ptary[1].Y) { ftop = m_ptary[0].Y; } else { ftop = m_ptary[0].Y - fWidth; } m_ptary[0].X = fleft; m_ptary[0].Y = ftop; m_ptary[1].X = m_ptary[0].X + fWidth; m_ptary[1].Y = m_ptary[0].Y + fWidth; } else { m_ptary[0].X = (float)rct.left; m_ptary[0].Y = (float)rct.top; m_ptary[1].X = (float)rct.right; m_ptary[1].Y = (float)rct.bottom; } }
void CTipWnd::AddString(LPCTSTR ss, COLORREF col /*= -1*/, CPoint * ppt /*= NULL*/, UINT fmt /*= 0*/) #endif { ASSERT(col_.size() == str_.size()); ASSERT(fmt_.size() == str_.size()); ASSERT(rct_.size() == str_.size()); str_.push_back(StringType(ss)); col_.push_back(col == -1 ? m_text_colour : col); fmt_.push_back(fmt == 0 ? m_fmt : fmt); CRect rct(0,0,0,0); // Work out how big the text is CClientDC dc(this); CFont *pOldFont = (CFont*)dc.SelectStockObject(m_stock_font); ASSERT(pOldFont != NULL); #if _MSC_VER >= 1300 ::DrawTextW(dc.m_hDC, (LPCWSTR)str_.back(), str_.back().GetLength(), &rct, DT_CALCRECT | fmt_.back()); #else dc.DrawText(str_.back(), &rct, DT_CALCRECT | fmt_.back()); #endif dc.SelectObject(pOldFont); // Work out where to put the text if (ppt != NULL) rct.MoveToXY(*ppt); // move to the specified posn else if (!rct_.empty()) rct.MoveToY(rct_all_.Height()); // put underneath the last one rct_.push_back(rct); ::UnionRect(&rct, &rct_all_, &rct_.back()); rct_all_ = rct; // Resize the window to accommodate the new string rct.InflateRect(m_margins+CSize(1,1)); SetWindowPos(NULL, 0, 0, rct.Width(), rct.Height(), SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); Invalidate(); ASSERT(col_.size() == str_.size()); ASSERT(fmt_.size() == str_.size()); ASSERT(rct_.size() == str_.size()); }
//��������������������������������������������������������������������������� // WinMain //��������������������������������������������������������������������������� int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { ushort width = 640; ushort height = 480; int bpp = 16; screen_type scrndevice = SCREEN_DIB; dword scrnflags = 0; float gamma = 1.0f; BOOL use_dinput = FALSE; char palname[256]; strcpy(palname,"DEFAULT.PAL"); //��� Process INI { XFParseINI ini; if (!ini.open("VIEWER.INI",XF_OPEN_READ)) { char buff[256]; //��� Screen parameters if (!ini.section("Screen")) { if (!ini.read("FullScreen",buff)) { strlwr(buff); if (strstr(buff,"yes")) scrnflags |= VNGO_SET_RESOLUTION; } if (!ini.read("Device",buff)) { strlwr(buff); if (strstr(buff,"ddraw")) scrndevice = SCREEN_DDRAW; else if (strstr(buff,"d3d")) scrndevice = SCREEN_D3D; else scrndevice = SCREEN_DIB; } if (!ini.read("Resolution",buff)) { strlwr(buff); if (strstr(buff,"320x240x8")) { width = 320; height = 240; bpp = 8; } else if (strstr(buff,"640x480x8")) { width = 640; height = 480; bpp = 8; } else if (strstr(buff,"640x480x15")) { width = 640; height = 480; bpp = 15; } else if (strstr(buff,"640x480x16")) { width = 640; height = 480; bpp = 16; } } if (!ini.read("Palette",buff)) strncpy(palname,buff,sizeof(palname)); if (!ini.read("Gamma",buff)) { gamma = float(atof(buff)); if (gamma < 0.5f) gamma = 0.5f; else if (gamma > 2.0f) gamma = 2.0f; } } //��� Startup parameters if (!ini.section("Startup")) { if (!ini.read("DirectInput",buff)) { strlwr(buff); if (strstr(buff,"yes")) use_dinput = TRUE; } } } } //��� Initialize Windows //��� If we are already running, this routine will reactivate the older //��� application and return failure. if (!InitApplication (hInstance, nCmdShow, width, height)) return 1; //��� Initializes MythOS //��� Initialize the MythOS system MythOS = new MythosSystem (MYTHOS_MEM_SIZE); if (!MythOS) return 1; //��� Create the devices if (use_dinput) { Devs = new MaxDevicesDirectX (hWndClient); if (!Devs) return 1; if (!Devs->is_mouse_present() || !Devs->is_keyboard_present()) { delete Devs; Devs = new MaxDevicesWin32 (hWndClient); } } else Devs = new MaxDevicesWin32 (hWndClient); if (!Devs) return 1; //��� Finish MythOS initialization if (MythOS->init (MYTHOS_ESCHER_ARENA_SIZE, MYTHOS_ESCHER_SORT_SIZE, 0)) return 1; MythOS->Vangogh.set_gamma(gamma); //��� Install Fonts if (gberg_install_font("ARIAL-15.IFF", 0)) return 1; //��� Setup palette and screen manager for(;;) { if (Palette) { delete Palette; Palette = 0; } if (Screen) { delete Screen; Screen = 0; } //��� Create palette switch (bpp) { case 8: Palette = new VngoPal8; break; case 15: Palette = new VngoPal15; break; case 16: Palette = new VngoPal16; break; } if (!Palette || Palette->init(0,palname)) return 1; //��� Create screen manager switch (scrndevice) { case SCREEN_DIB: Screen = new VngoDIB(hWndClient); break; case SCREEN_DDRAW: Screen = new VngoDirectDraw(hWndClient); break; case SCREEN_D3D: Screen = new VngoDirect3D(hWndClient); scrnflags |= VNGO_3DDEVICE | VNGO_ALLOC_ZBUFFER; break; } if (!Screen || Screen->get_initstate()) return 1; VNGError err = Screen->set_mode (width, height, (bpp == 8) ? 8 : 16, Palette, scrnflags); if (err == VNGO_NO_ERROR) break; else if (err == VNGO_NEEDS_PAL8) bpp = 8; else if (err == VNGO_NEEDS_PAL15) bpp = 15; else if (err == VNGO_NEEDS_PAL16) bpp = 16; else return 1; } //��� Create viewport switch (scrndevice) { case SCREEN_DIB: if (bpp == 8) { Vport = new VngoVportDB8(width,height, ((VngoDIB*)Screen)->gmap,0,Palette, VNGO_ZBUFFER_DEV); } else { Vport = new VngoVportDB16(width,height, ((VngoDIB*)Screen)->gmap,0,Palette, VNGO_ZBUFFER_DEV); } break; case SCREEN_DDRAW: if (bpp == 8) { Vport = new VngoVportDD8(((VngoDirectDraw*)Screen)->SurfaceManager, 0, Palette, VNGO_ZBUFFER_DEV); } else { Vport = new VngoVportDD16(((VngoDirectDraw*)Screen)->SurfaceManager, 0, Palette, VNGO_ZBUFFER_DEV); } break; case SCREEN_D3D: { VngoRect rct(0,0,width,height); Vport = new VngoVportD3D(rct, Palette, VNGO_ZBUFFER_DEV, Screen); } break; } if (!Vport) return 1; gberg_color(Palette->get_index(VngoColor24bit(255,255,255)), VNGO_TRANSPARENT); //��� Create viewer application instance Viewer *view = new Viewer; if (!view || !view->create()) return 1; //��� Main Loop while (PumpWindows()) { Devs->update(); view->process_events(); view->render(); Screen->flip(); } //��� Destroy viewer application delete view; //����������������������������������������������������������� Termination if (Vport) { delete Vport; Vport=0; } if (Palette) { delete Palette; Palette=0; } if (Screen) { delete Screen; Screen=0; } if (Devs) { delete Devs; Devs=0; } if (MythOS) { delete MythOS; MythOS=0; } return 0; }
int CBirchCtrl::DrawNodesRecursive( CDC* pDC, HTREENODE pNode, int y, CPen* linesPen, CPen* marksPen, CRect rFrame ) { if (!m_birch) return 0; if (!pNode->bVisible) return (y-1); CRect rNode; // The node's location and dimensions on screen rNode.left = m_iIndent*pNode->iNodeLevel+3; rNode.top = y; rNode.right = rFrame.right - m_iPadding; rNode.bottom = y + m_iLineHeight; pNode->rNode.CopyRect( rNode ); // Record the rectangle if (pNode->pParent==m_birch->GetTopNode()) { CRect rct(0,rNode.top+1,rFrame.right,rNode.bottom-1); themeData.DrawThemedRect(pDC,&rct,TRUE); pDC->FillSolidRect(rct.left,rct.top-1,rct.Width(),1,GetSysColor(COLOR_3DFACE)); pDC->FillSolidRect(rct.left,rct.bottom,rct.Width(),1,GetSysColor(COLOR_3DSHADOW)); } int iJointX = pNode->rNode.left - m_iIndent - 6; int iJointY = pNode->rNode.top + ( m_iLineHeight / 2 ); int iDispY = iJointY - pNode->pParent->rNode.top - ( m_iLineHeight / 2 ); if( rNode.bottom > 0 && rNode.top < rFrame.bottom ) { COLORREF cr = ( pNode->bUseDefaultTextColor )? m_crDefaultTextColor:pNode->crText; COLORREF crOldText = pDC->SetTextColor( cr ); size_t bmps_cnt = pNode->item_bitmaps.size(); int buf_len = 1; if (bmps_cnt>0) { for (size_t jj=0;jj<bmps_cnt;jj++) { int bw = pNode->item_bitmaps[jj]->GetWidth(); int bh = pNode->item_bitmaps[jj]->GetHeight(); CRect destR(pNode->rNode.left+buf_len, pNode->rNode.top+m_iLineHeight/2-bh/2, pNode->rNode.left+buf_len+bw, pNode->rNode.top+m_iLineHeight/2+bh/2); CRect srcR(0, 0, bw,bh); //pDC->Rectangle(destR); pNode->item_bitmaps[jj]->Draw(pDC,&destR,&srcR); buf_len += bw+1; //CTreeCtrl::CreateDragImage() } } pDC->DrawText( pNode->csLabel, CRect(rNode.left+buf_len+2,rNode.top, rNode.right,rNode.bottom), DT_LEFT | DT_SINGLELINE | DT_VCENTER ); pDC->SetTextColor( crOldText ); // draw lines START // If the parent is not the top node, throw a connecting line to it if( pNode->pParent != m_birch->GetTopNode() ) { // How far up from the joint is the parent? // Use 1 pixel wide rectangles to draw lines pDC->SelectObject(linesPen); pDC->MoveTo(iJointX, iJointY); pDC->LineTo(iJointX+m_iIndent, iJointY); //if (pNode==pNode->pParent->pLastChild) { pDC->MoveTo(iJointX, iJointY); pDC->LineTo(iJointX, iJointY-iDispY+5); } } pDC->SelectObject(marksPen); // Put a solid dot to mark a node if (pNode->pFirstChild != NULL) { pDC->Rectangle(iJointX + m_iIndent - 4, iJointY - 4, iJointX + m_iIndent +5, iJointY +5); pDC->MoveTo(iJointX + m_iIndent - 2, iJointY); pDC->LineTo(iJointX + m_iIndent + 3, iJointY); if (!pNode->bOpen) { pDC->MoveTo(iJointX + m_iIndent, iJointY - 2); pDC->LineTo(iJointX + m_iIndent, iJointY + 3); } } // Hollow out the dot if the node has no childs else { pDC->Ellipse(iJointX + m_iIndent - 1, iJointY - 1, iJointX + m_iIndent +2, iJointY +2); } // draw lines END } else { pDC->SelectObject(linesPen); if( pNode->pParent != m_birch->GetTopNode()/* && pNode==pNode->pParent->pLastChild*/) { pDC->MoveTo(iJointX, iJointY); pDC->LineTo(iJointX, iJointY-iDispY+5); } } // If there are no child or siblings, then this branch is done if( pNode->pFirstChild == NULL) return pNode->rNode.bottom;//pNode->rNode.Height(); // If the node is open AND it has childs, then draw those int iLastNodePos=pNode->rNode.bottom; if( pNode->bOpen) { HTREENODE curTreeNode = pNode->pFirstChild ; while (curTreeNode) { iLastNodePos = DrawNodesRecursive( pDC, curTreeNode, iLastNodePos+1, linesPen, marksPen, rFrame ); curTreeNode = curTreeNode->pNextSibling; } } return iLastNodePos; }
void Tracker::track(int nsamples, double dynamicp) { Mat frame; Mat hsvFrame; bool finishInnerLoop = false; Particles pf(nsamples, dynamicp); bool wasInit = false; namedWindow("fr", CV_WINDOW_KEEPRATIO); createTrackbar("kapa", "fr", &(pf.measure_param), 1000, NULL); setMouseCallback("fr", wrappedOnMouse, (void*)this); do{ (*capture) >> frame; if(!frame.empty()){ if(wasInit){ cvtColor(frame, hsvFrame , CV_RGB2HSV); pf.resample(); pf.predict(); pf.measure(hsvFrame); pf.new_state(hsvFrame); for(int i=0 ; i<pf.pnum ; i++) { circle(frame, Point(pf.particles[i].pos_x, pf.particles[i].pos_y), 5, Scalar(0,0,255)); circle(frame, Point((int)pf.mean_pos_x, (int)pf.mean_pos_y), 5, Scalar(255,0,0), -1); // rectangle(frame, Point(pf.particles[i].pos_x + (pf.width>>1), pf.particles[i].pos_y + (pf.height>>1)), // Point(pf.particles[i].pos_x - (pf.width>>1), pf.particles[i].pos_y - (pf.height>>1)), // Scalar(0,255,0)); } } imshow("fr", frame); finishInnerLoop = false; switch(waitKey(2) & 255){ case 't': // zastaveni prehravani a moznost oznacit objekt mysi filling = false; filled = false; while(!finishInnerLoop){ Mat frameCopy = frame.clone(); // vykresleni obdelniku, pokud tahnu mysi if(filling) rectangle(frameCopy, Point(px1, py1), Point(px2, py2), Scalar(255), 2); if(filled){ filling = false; filled = false; } imshow("fr", frameCopy); switch(waitKey(2) & 255){ case 't': case ' ': finishInnerLoop = true; Rect rct(Point(px1,py1), Point(px2,py2)); if(rct.width <= 0 || rct.height <= 0) break; cvtColor(frame, hsvFrame , CV_RGB2HSV); pf.init_samples(hsvFrame, rct); wasInit = true; break; } } break; } writer->write(frame); } } while( !frame.empty() ); }
void CRectangle::NormalizeData() { CPoint ptLT, ptRB; ptLT.x = (int)m_ptary[0].X; ptLT.y = (int)m_ptary[0].Y; ptRB.x = (int)m_ptary[1].X; ptRB.y = (int)m_ptary[1].Y; CRect rct(ptLT,ptRB); rct.NormalizeRect(); CPoint ptCenter = rct.CenterPoint(); if((rct.Width() < 5 || rct.Height() < 5) && RS_SQUARE == m_nRStyle) { m_ptary[0].X = (float)(ptCenter.x - 20); m_ptary[0].Y = (float)(ptCenter.y - 20); m_ptary[1].X = (float)(ptCenter.x + 20); m_ptary[1].Y = (float)(ptCenter.y + 20); return; } else if(rct.Width() < 5 || rct.Height() < 5) { m_ptary[0].X = (float)(ptCenter.x - 20); m_ptary[0].Y = (float)(ptCenter.y - 30); m_ptary[1].X = (float)(ptCenter.x + 20); m_ptary[1].Y = (float)(ptCenter.y + 30); return; } if(RS_SQUARE == m_nRStyle) { float fleft = 0, ftop = 0; float fWidth = (float)min(rct.Width(),rct.Height()); if(m_ptary[0].X <= m_ptary[1].X) { fleft = m_ptary[0].X; } else { fleft = m_ptary[0].X - fWidth; } if(m_ptary[0].Y <= m_ptary[1].Y) { ftop = m_ptary[0].Y; } else { ftop = m_ptary[0].Y - fWidth; } m_ptary[0].X = fleft; m_ptary[0].Y = ftop; m_ptary[1].X = m_ptary[0].X + fWidth; m_ptary[1].Y = m_ptary[0].Y + fWidth; } else { m_ptary[0].X = (float)rct.left; m_ptary[0].Y = (float)rct.top; m_ptary[1].X = (float)rct.right; m_ptary[1].Y = (float)rct.bottom; } }