Exemplo n.º 1
0
	void Panel::_onMaskPatches( Patches& patches, const Rect& geo, const Rect& clip, WgBlendMode blendMode )
	{
		//TODO: Don't just check isOpaque() globally, check rect by rect.
		if( (m_bOpaque && blendMode == WG_BLENDMODE_BLEND) || blendMode == WG_BLENDMODE_OPAQUE )
		{
			patches.sub( Rect(geo,clip) );
			return;
		}
		
		switch( m_maskOp )
		{
			case WG_MASKOP_RECURSE:
			{
				Rect childGeo;
				PanelHook * p = static_cast<PanelHook*>(_firstHookWithGeo( childGeo ));
	
				while(p)
				{
					if( p->isVisible() )
						p->_widget()->_onMaskPatches( patches, childGeo + geo.pos(), clip, blendMode );
					p = static_cast<PanelHook*>(_nextHookWithGeo( childGeo, p ));
				}
				break;
			}
			case WG_MASKOP_SKIP:
				break;
			case WG_MASKOP_MASK:
				patches.sub( Rect(geo,clip) );
				break;
		}
	}
Exemplo n.º 2
0
/// Get cached MD5 hash for a given patch file
bool Patcher::GetHash(char * pat, uint8 mymd5[16]) {
	for (Patches::iterator i = _patches.begin(); i != _patches.end(); ++i)
		if (!stricmp(pat, i->first.c_str())) {
			memcpy(mymd5, i->second->md5, 16);
			return true;
		}

	return false;
}
Exemplo n.º 3
0
	void Widget::_maskPatches( Patches& patches, const Rect& geo, const Rect& clip, BlendMode blendMode )
	{
		if( (m_bOpaque && blendMode == BlendMode::Blend) || blendMode == BlendMode::Replace )
		{
			patches.sub( Rect( geo, clip ) );
		}
	}
Exemplo n.º 4
0
	void SplitPanel::_collectPatches(Patches& container, const Rect& geo, const Rect& clip)
	{
		if (m_pSkin)
			container.add(Rect(geo, clip));
		else
		{
			if (m_firstChild.pWidget)
				m_firstChild.pWidget->_collectPatches(container, m_firstChild.geo + geo.pos(), clip );

			if( m_pHandleSkin )
				container.add(Rect(m_handleGeo, clip));

			if (m_secondChild.pWidget)
				m_secondChild.pWidget->_collectPatches(container, m_secondChild.geo + geo.pos(), clip );
		}
	}
Exemplo n.º 5
0
	void SplitPanel::_maskPatches(Patches& patches, const Rect& geo, const Rect& clip, BlendMode blendMode)
	{
		{
			//TODO: Don't just check isOpaque() globally, check rect by rect.
			if ((m_bOpaque && blendMode == BlendMode::Blend) || blendMode == BlendMode::Replace)
				patches.sub(Rect(geo, clip));
			else
			{
				if (m_firstChild.pWidget)
					m_firstChild.pWidget->_maskPatches(patches, m_firstChild.geo + geo.pos(), clip, blendMode );

				if (m_pHandleSkin && m_pHandleSkin->isOpaque() )
					patches.sub(Rect(m_handleGeo, clip));

				if (m_secondChild.pWidget)
					m_secondChild.pWidget->_maskPatches(patches, m_secondChild.geo + geo.pos(), clip, blendMode );
			}
		}
	}
Exemplo n.º 6
0
	void Container::_collectPatches( Patches& container, const Rect& geo, const Rect& clip )
	{
		if( m_pSkin )
			container.add( Rect( geo, clip ) );
		else
		{
			Rect childGeo;
			Hook * p = _firstHookWithGeo( childGeo );
	
			while(p)
			{
				if( p->_isVisible() )
					p->_widget()->_collectPatches( container, childGeo + geo.pos(), clip );
				p = _nextHookWithGeo( childGeo, p );
			}
		}
	}
Exemplo n.º 7
0
	void Container::_maskPatches( Patches& patches, const Rect& geo, const Rect& clip, BlendMode blendMode )
	{
		//TODO: Don't just check isOpaque() globally, check rect by rect.
		if( (m_bOpaque && blendMode == BlendMode::Blend) || blendMode == BlendMode::Replace)
			patches.sub( Rect(geo,clip) );
		else
		{
			Rect childGeo;
			Hook * p = _firstHookWithGeo( childGeo );
	
			while(p)
			{
				if( p->_isVisible() )
					p->_widget()->_maskPatches( patches, childGeo + geo.pos(), clip, blendMode );
				p = _nextHookWithGeo( childGeo, p );
			}
		}
	}
Exemplo n.º 8
0
	void Widget::_collectPatches( Patches& container, const Rect& geo, const Rect& clip )
	{
			container.add( Rect( geo, clip ) );
	}
Exemplo n.º 9
0
	void Widget::_renderPatches( GfxDevice * pDevice, const Rect& _canvas, const Rect& _window, const Patches& patches )
	{
		pDevice->setClipList(patches.size(), patches.begin());
		_render( pDevice, _canvas, _window );
	}
Exemplo n.º 10
0
void track3(ImageSource::InputDevice input, int numBaseClassifier, float overlap, float searchFactor, char* resultDir, Rect initBB, char* source = NULL)
{
	unsigned char *curFrame=NULL;
        int key;
	//choose the image source
	ImageSource *imageSequenceSource;
	switch (input)
	{
	case ImageSource::AVI:
		imageSequenceSource = new ImageSourceAVIFile(source);
		break;
	case ImageSource::DIRECTORY:
		imageSequenceSource = new ImageSourceDir(source);
		break;
	case ImageSource::USB:
		imageSequenceSource = new ImageSourceUSBCam();
		break;
	default:
		return;
	}

	ImageHandler* imageSequence = new ImageHandler (imageSequenceSource);
	imageSequence->getImage();

	imageSequence->viewImage ("Tracking...", false);

		trackingRect=initBB;


	curFrame = imageSequence->getGrayImage ();
	ImageRepresentation* curFrameRep = new ImageRepresentation(curFrame, imageSequence->getImageSize());
	Rect wholeImage;
	wholeImage = imageSequence->getImageSize();


        // Pula o inicio do video
        for(int t = 0; t < 60; t++, imageSequence->getImage());


        IplImage *image;
        image = imageSequence->getIplImage();


//cvWaitKey(0);


        printf ("init tracker...");
        Classifier* tracker;
        tracker = new Classifier(image, trackingRect);
        printf (" done.\n");

	Size trackingRectSize;
	trackingRectSize = trackingRect;
	printf ("start tracking (stop by pressing any key)...\n\n");

// Inicializa o detector
Detector* detector;
detector = new Detector(tracker->getClassifier());
Rect trackedPatch = trackingRect;
Rect validROI;
validROI.upper = validROI.left = 0;
validROI.height = image->height;
validROI.width = image->width;


	key=(char)-1;
        while (key==(char)-1)
	{





		imageSequence->getImage();
                image = imageSequence->getIplImage();




curFrame = imageSequence->getGrayImage ();
if (curFrame == NULL) break;

//calculate the patches within the search region
Patches *trackingPatches;
Rect searchRegion;
searchRegion = getTrackingROI(searchFactor, trackedPatch, validROI);
trackingPatches = new PatchesRegularScan(searchRegion, wholeImage, trackingRectSize, overlap);

curFrameRep->setNewImageAndROI(curFrame, searchRegion);

detector->classifySmooth(curFrameRep, trackingPatches);

trackedPatch = trackingPatches->getRect(detector->getPatchIdxOfBestDetection());

if (detector->getNumDetections() <= 0){printf("Lost...\n");break;}



                // Treina o classificador
                tracker->train(image,trackedPatch);


float alpha, confidence, eval;

alpha = tracker->getSumAlphaClassifier();
confidence = detector->getConfidenceOfBestDetection() / alpha;
eval = tracker->classify(image, trackedPatch);

printf("alpha: %5.3f confidence: %5.3f evalOficial: %5.3f ", alpha, confidence, eval);

int orig = trackedPatch.upper;
trackedPatch.upper -= 5;
for(int i = 0; i < 10; i++){
    eval = tracker->classify(image, trackedPatch);
    printf("%5.3f ", eval);
    trackedPatch.upper += 1;
    imageSequence->paintRectangle (trackedPatch, Color (0,255,0), 1);
}
trackedPatch.upper = orig;

printf("\n");




		//display results
                imageSequence->paintRectangle (trackedPatch, Color (255,0,0), 5);
		imageSequence->viewImage ("Tracking...", false);
		key=cvWaitKey(200);
	}

	//clean up
	delete tracker;
	delete imageSequenceSource;
	delete imageSequence;
	if (curFrame == NULL)
		delete[] curFrame;
	delete curFrameRep;
}