Exemplo n.º 1
0
//---------------------------------------------------------------------------
void ofxTSPSPeopleTracker::draw(int x, int y, int mode)
{
    // run lean + mean if we're minimized
    if (p_Settings->bMinimized) return;
	ofPushMatrix();
		ofTranslate(x, y, 0);
		// draw the incoming, the grayscale, the bg and the thresholded difference
		ofSetHexColor(0xffffff);
	
		//draw large image
		if (activeViewIndex ==  CAMERA_SOURCE_VIEW){
			cameraView.drawLarge(activeView.x, activeView.y, activeView.width, activeView.height);		
			gui.drawQuadGui( activeView.x, activeView.y, activeView.width, activeView.height );
		} else if ( activeViewIndex == ADJUSTED_CAMERA_VIEW){
			adjustedView.drawLarge(activeView.x, activeView.y, activeView.width, activeView.height);				
		} else if ( activeViewIndex == REFERENCE_BACKGROUND_VIEW){
			bgView.drawLarge(activeView.x, activeView.y, activeView.width, activeView.height);			
		} else if ( activeViewIndex == PROCESSED_VIEW){ 
			processedView.drawLarge(activeView.x, activeView.y, activeView.width, activeView.height);
		} else if ( activeViewIndex == DATA_VIEW ){
			ofPushMatrix();
				ofTranslate(activeView.x, activeView.y);
				drawBlobs(activeView.width, activeView.height);
			ofPopMatrix();
			dataView.drawLarge(activeView.x, activeView.y, activeView.width, activeView.height);
		}
		
		//draw all images small
		cameraView.draw();
		adjustedView.draw();
		bgView.draw();
		processedView.draw();
		dataView.draw();	
		
		ofPushMatrix();
			ofTranslate(dataView.x, dataView.y);
			drawBlobs(dataView.width, dataView.height);
		ofPopMatrix();
		
	ofPopMatrix();
	
	//draw framerate in a box
	
	char frmrate[1024];
	sprintf(frmrate, "Frame rate: %f", ofGetFrameRate() );
	
	ofPushStyle();
	ofFill();
	ofSetColor(196,182,142);
	ofRect(cameraView.x, cameraView.y + cameraView.height + spacing*3 + 8, cameraView.width*2 + spacing, spacing*4);
	ofPopStyle();
	
	if (!bFontLoaded) ofDrawBitmapString(frmrate, cameraView.x + 10, cameraView.y + 10 + cameraView.height + spacing*5);
	else font.drawString(frmrate, (int)cameraView.x + 10, (int) (cameraView.y + 10 + cameraView.height + spacing*5));
}
Exemplo n.º 2
0
void WallSimulator::update(){
	u_long now = ofGetElapsedTimeMillis();
	particles.update(now);
	//glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
	//glEnable(GL_POINT_SPRITE);
	glowParticles.begin(true);
	drawBackground(0,0);
	ofPushMatrix();
	ofScale(wallWidth/640.,wallHeight/480.,1);
	particles.draw(0,0);
	//drawBlobs(0,0);
	ofPopMatrix();
	glowParticles.end();

	/*glowBlobs.begin(true);
	ofSetColor(255);
	ofPushMatrix();
	ofScale(wallWidth/640.,wallHeight/480.,1);
	drawBlobs(0,0);
	ofPopMatrix();
	glowBlobs.end();*/
	//glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
	//glDisable(GL_POINT_SPRITE);


	//drawBackground(0,0);
	fbo.begin();
	if(!particles.empty()){
		filterShader.begin();
		filterShader.setUniformTexture("fboCurrent",glowParticles.getTextureReference(),0);
		filterShader.setUniformTexture("fboPrev",fbo.getTextureReference(),1);
		filterShader.setUniform1f("filterFactor",.95);
		glowParticles.draw(0,0);
		filterShader.end();
		lastTimeParticles = now;
	}else{
		filterShader.begin();
		filterShader.setUniformTexture("fboCurrent",glowParticles.getTextureReference(),0);
		filterShader.setUniformTexture("fboPrev",fbo.getTextureReference(),1);
		filterShader.setUniform1f("filterFactor",ofMap(now-lastTimeParticles,0,2000,.95,0.6,true));
		glowParticles.draw(0,0);
		filterShader.end();
	}
	fbo.end();

	glowBlobs.begin(true);
	fbo.draw(0,0);
	ofPushMatrix();
	ofScale(wallWidth/640.,wallHeight/480.,1);
	drawBlobs(0,0);
	ofPopMatrix();
	//glowBlobs.draw(0,0);
	glowBlobs.end();
	glowBlobs.readToPixels(pixels);
	for(int y=0;y<wallHeight;++y){
		for(int x=0;x<wallWidth;++x){
			mesh.getColors()[y*wallWidth+x]=pixels.getColor(x,y);
		}
	}
}
Exemplo n.º 3
0
void Blobs02 :: drawBox2d ()
{
	ofSetColor( 255, 255, 255 );
	
	ofFill();				// fill
	drawBlobs();
	
	ofEnableSmoothing();	// lines smoothed.
	ofNoFill();
	drawBlobs();
	ofDisableSmoothing();
	
	for( int i=0; i<blobs.size(); i++ )
	{
		if( bDrawNodes )
		{
			for( int j=0; j<blobs[ i ].nodes.size(); j++)
			{
				blobs[ i ].nodes[ j ].draw();
			}
		}
		
		if( bDrawJoints )
		{
			for( int j=0; j<blobs[ i ].nodeJoints.size(); j++)
			{
				blobs[ i ].nodeJoints[ j ].draw();
			}
		}
	}
	
	ofSetColor( 30, 30, 30 );
	
	ofFill();				// ball fill
	drawBalls();
	
	ofEnableSmoothing();	// ball lines smoothed.
	ofNoFill();
	drawBalls();
	ofDisableSmoothing();
}
Exemplo n.º 4
0
void TrackerThread::calcBlobs(BitmapPtr pTrackBmp, BitmapPtr pTouchBmp, long long time) 
{
    BlobVectorPtr pTrackComps;
    BlobVectorPtr pTouchComps;
    {
        ScopeTimer timer(ProfilingZoneComps);
        boost::mutex::scoped_lock lock(*m_pMutex);
        BitmapPtr pDestBmp;
        if (m_bCreateFingerImage) {
            Pixel32 Black(0x00, 0x00, 0x00, 0x00);
            FilterFill<Pixel32>(Black).applyInPlace(
                    m_pBitmaps[TRACKER_IMG_FINGERS]);
            pDestBmp = m_pBitmaps[TRACKER_IMG_FINGERS];
        }
        {
            if (m_TrackThreshold != 0) {
                pTrackComps = findConnectedComponents(pTrackBmp, m_TrackThreshold);
                calcContours(pTrackComps);
                drawBlobs(pTrackComps, pTrackBmp, pDestBmp, m_TrackThreshold, false);
                pTrackComps = findRelevantBlobs(pTrackComps, false);
            }
            if (m_TouchThreshold != 0) {
                pTouchComps = findConnectedComponents(pTouchBmp, m_TouchThreshold);
                pTouchComps = findRelevantBlobs(pTouchComps, true);
                correlateHands(pTrackComps, pTouchComps);
                drawBlobs(pTouchComps, pTouchBmp, pDestBmp, m_TouchThreshold, true);
            }
        }
        // Send the blobs to the BlobTarget.
        {
            ScopeTimer timer(ProfilingZoneUpdate);
            m_pTarget->update(pTrackComps, pTouchComps, time);
        }
    }
    
}
void kinactorApp::kinactorDraw()
{
    // JUST CONTOUR FOR NOW
    // ORIGINAL IMAGE SIZE IS 640x480
    
    ofPushMatrix();
	ofScale(scaleFactor, scaleFactor, 1.0);
	ofTranslate(mtrx, mtry, 1.0);
    
    if (bBox)
        drawBox();
    
    drawBlobs();
    ofPopMatrix();
}
Exemplo n.º 6
0
void CameraWorker::onTimeout()
{
    if(isCamera)
    {
        displayFrame = displayCamFrame;
        frame = cvQueryFrame(capture);
    }
    else
    {
        displayFrame = displayArenaFrame;
        frame = arenaFrame;
    }
    if(!frame)
        return;
    frame->roi = roi;
    cvResize(frame, calibFrame, CV_INTER_NN);
    cvCopy(calibFrame, displayFrame);
    if(isThreshold)
        colorImage(calibFrame, displayFrame);    
    if(isBlob)
    {
        makeBlobImage(frame, blobImage);
        b->detectBlobs(blobImage, a.getZoneImage());
        blobDataArr = b->getBlobDataArr();
        drawBlobs(displayFrame, blobDataArr);
        myMutex->lock();
        bs->populateFromBlobData(blobDataArr);
        bs->bombDepositPoint = a.getBombDrop();
        bs->resourceDepositPoint = a.getMineDrop();
        bs->startCorner = a.getStartCorner();
        myMutex->unlock();
        emit beliefStateReady(bs);
    }
    if(isArenaCalib)
    {
        a.drawArenaDisplay(displayFrame);
    }
    cvCvtColor(displayFrame, displayFrame,CV_BGR2RGB);
    QImage qimg((uchar*)displayFrame->imageData, displayFrame->width, displayFrame->height, displayFrame->widthStep, QImage::Format_RGB888);
    myMutex->lock();
    if(myPixmap)
        delete myPixmap;
    myPixmap = new QPixmap(QPixmap::fromImage(qimg));
    myMutex->unlock();
    emit imageReady(myPixmap);
    timer->setSingleShot(true);
    timer->start(10);
}
Exemplo n.º 7
0
//--------------------------------------------------------------
void testApp::draw()
{
//	ofBackground( 20, 20, 20 );
	ofBackground( 40, 40, 40 );
	
	glPushMatrix();
	glTranslatef( imageRect.x, imageRect.y, 0 );
	
	glPushMatrix();
	glScalef( screenScale, screenScale, 0 );

	drawSourceImage();

	glPushMatrix();
//	glTranslatef( 0, imageColor.height + 30, 0 );
	glTranslatef( imageColor.width + 30, 0, 0 );

	drawHSV();
	
	glPushMatrix();
	glTranslatef( 0, hsvProcessedImg.height + 30, 0 );
	
	drawMotionImage();
	
	glPushMatrix();
	glTranslatef( 0, motionImg.height + 30, 0 );
	
	drawBlobs();

	glPushMatrix();
	glTranslatef( 0, blobImg.height + 30, 0 );
	
	drawFinal();
	
	glPopMatrix();
	glPopMatrix();
	glPopMatrix();
	glPopMatrix();
	glPopMatrix();
	
	drawTesseractText();
	
	glPopMatrix();
	
	gui.draw();
	
	screenGrab.save();
}
Exemplo n.º 8
0
/** Displays images that have had blobdetection performed on them.

 */
void Camera::displayBlobs(char* windowName){

	cvNamedWindow(windowName,0);
	// Esc breaks loop.  Highgui is responding strangly to close window button
	while (1) {

		frame = captureImage();
		drawBlobs(frame);
		cvShowImage(windowName, frame);
		cvReleaseImage(&frame);

		char c = cvWaitKey(33);
		if( c == 27 ) break;
	}

	cvDestroyWindow(windowName);
	return;
}
Exemplo n.º 9
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofBackground(0, 0, 0);
    fbo.begin();
    ofClear(0.,0.,0., 0.);
    if(playMode==0){drawWaves();}
    else if (playMode==1){drawBlobs();}
    
    fbo.end();
    fbo.readToPixels(pix);
    pix.getData();
    
    for(int i=0; i<totalSpeakers;i++){
        if(pix.getColor(solenoidArray[i].pos.x, solenoidArray[i].pos.y).r>0 && solenoidArray[i].isActive==false){
            solenoidArray[i].isActive=true;
            solenoidArray[i].timeStamp=ofGetElapsedTimeMillis();
        }
        
        if(solenoidArray[i].isActive != activeSolenoid[i]){
            ofxOscMessage n;
            n.setAddress("/OF");
            n.addFloatArg(i);
            n.addIntArg(playMode); // playMode
            n.addIntArg(solenoidArray[i].isActive); //is active?
            n.addIntArg(nodeID); //index
            sender.sendMessage(n);
            activeSolenoid[i] = solenoidArray[i].isActive;// update our reference node
            cout << "OSC: Noid "<< i << " is " << solenoidArray[i].isActive << " -- nodeID: " << nodeID << endl;
        }
    }
    
    //    fbo.draw(0,0);
    
    //    ofDrawBitmapString(msg, ofGetWidth()/2, ofGetHeight()/2);
    for (int i=0; i<totalSpeakers; i++) {
        drawCircle(i);
    }
    
}
Exemplo n.º 10
0
void Tracker::draw() {

  // draw the textures.
  tex_painter.clear();
  {
    tex_painter.texture(bg_buffer.getLastUpdatedTexture(), 0, h, w, -h);
    tex_painter.texture(edt.getThresholdedTex(), w, 0, w, h);
  }
  tex_painter.draw();

  // draw CV info
  shape_painter.clear();
  {
    drawContours(0, 0);
    drawBlobs(0, 0);
  }
  shape_painter.draw();

  // some labels.
  font.clear();
  font.write(5, h + 10, "Input and contours");
  font.write(w, h + 10, "Background segmentation");
  font.draw();
}