示例#1
0
Background :: Background(int numberOfTextures){
    
    ofEnableAlphaBlending();
    
    //loads all the background, foreground and cloud images to memory in each vector. the folders are arranges in the same way for each image and have the same file names for each type of BG. 
    for(int i = 0; i < numberOfTextures; i ++){
        
        
        backgroundImages.push_back(ofImage());
        foregroundImages.push_back(ofImage());
        cloudImages.push_back(ofImage());
        
        string result = "";
        stringstream currentCombo;
        currentCombo << i;
        result = currentCombo.str();
        
        backgroundImages[i].loadImage(ofToDataPath("BG/" +result + ".png"));
        foregroundImages[i].loadImage(ofToDataPath("GRASS/" +result + ".png"));
        cloudImages[i].loadImage(ofToDataPath("CLOUDS/" +result + ".png"));

    }
    
    currentBGType = 0;
    
}
示例#2
0
//--------------------------------------------------------------
void testApp::loadPicture(){
    
    banner.loadImage("image/banner.png");
    
    ofDirectory dir;
    int nFiles = dir.listDir("image/photos");
    if(nFiles) {
        for(int i=0; i<dir.numFiles(); i++) {
            string filePath = dir.getPath(i);
            images.push_back(ofImage());
            images.back().loadImage(filePath);
        }
        
    }
    
    nFiles = dir.listDir("image/shadows");
    if(nFiles) {
        for(int i=0; i<dir.numFiles(); i++) {
            string filePath = dir.getPath(i);
            shadows.push_back(ofImage());
            shadows.back().loadImage(filePath);
        }
    }
    
}
//--------------------------------------------------------------
void testApp::moveFrame(int distance){ 
	previewFrame = ofClamp(previewFrame + distance, -2, decoder.getCaptures().size()-1);

	ofLogNotice() << "Preview frame #" << previewFrame;
	if (previewFrame >= 0 && previewFrame < decoder.getCaptures().size())
		capturePreview = ofImage(decoder.getCaptures()[previewFrame]);
	if (previewFrame == -1)
		capturePreview = ofImage(decoder.getMean());
}
示例#4
0
void AppManager::draw(){
    ofBackground(0,0,0);
    ofSetColor(255);
    
    // draw shape and color I/O images

    ofRect(1, 1, 302, 302);
    ofImage(heightPixelsFromShapeDisplay).draw(2, 2, 300, 300);
    
    ofRect(305, 1, 302, 302);
    ofImage(heightPixelsForShapeDisplay).draw(306, 2, 300, 300);
    
    ofRect(609, 1, 302, 302);
    graphicsForShapeDisplay.draw(610, 2, 300, 300);
    
    ofRect(913, 1, 302, 302);
    ofImage(colorPixels).draw(914, 2, 300, 300);

    // draw this app's debugging gui, if selected
    if (showDebugGui) {
        currentApplication->drawDebugGui(1, 305);
    }

    // draw text
    int menuLeftCoordinate = 21;
    int menuHeight = 350;
    string title = currentApplication->getName() + (showDebugGui ? " - Debug" : "");
    ofDrawBitmapString(title, menuLeftCoordinate, menuHeight);
    menuHeight += 30;
    ofDrawBitmapString((string) "  '?' : " + (showGlobalGuiInstructions ? "hide" : "show") + " instructions", menuLeftCoordinate, menuHeight);
    if (showGlobalGuiInstructions) {
        menuHeight += 20;
        ofDrawBitmapString((string) "  '1' - '9' : select application", menuLeftCoordinate, menuHeight);
        menuHeight += 20;
        ofDrawBitmapString((string) "  '.' : turn debug gui " + (showDebugGui ? "off" : "on"), menuLeftCoordinate, menuHeight);
        menuHeight += 20;
        ofDrawBitmapString((string) "  ' ' : " + (paused ? "play" : "pause"), menuLeftCoordinate, menuHeight);
    }
    menuHeight += 30;

    // if there isn't already a debug gui, draw some more information
    if (!showDebugGui || currentApplication == applications["water"] || currentApplication == applications["stretchy"]) {
        ofRect(913, 305, 302, 302);
        ofImage(depthPixels).draw(914, 306, 300, 300);

        ofDrawBitmapString(currentApplication->appInstructionsText(), menuLeftCoordinate, menuHeight);
        menuHeight += 20;
    }

    // draw graphics onto projector
    bool shouldDrawProjectorGraphics = SHAPE_DISPLAY_IN_USE == INFORM_DISPLAY;
    if (shouldDrawProjectorGraphics) {
        graphicsForShapeDisplay.draw(projectorOffsetX, SHAPE_DISPLAY_PROJECTOR_OFFSET_Y, SHAPE_DISPLAY_PROJECTOR_SCALED_SIZE_X, SHAPE_DISPLAY_PROJECTOR_SCALED_SIZE_Y);
    };
}
示例#5
0
//----------------------------------------------
void ttChar::setup(ofxBox2d &characterWorld,
                   ofxBox2d &dummyWorld,
                   ttControl &ctrl,
                   ofPoint SetPos,
                   int iCharNum){
    
    control = &ctrl;
    bFixedMove = false;
    setPos = SetPos;
    getPos = SetPos;
    charNum = iCharNum;
    
    mirrorLeft = false;
 
    character.setPhysics(1000.0f, 0.0f, 0.3f);
    character.setup(characterWorld.getWorld(), setPos.x, setPos.y, setWidth, setHeight);


    character.setData(new ttSetData);
    ttSetData* sd = (ttSetData*)character.getData();
    if (charNum == 0) {
        sd->name = "char_A";
        
        ofDirectory dir;
        int nFiles = dir.listDir("sprites/girl");
        if (nFiles) {
            for (int i= 0; i<dir.numFiles(); i++) {
                string filePath = dir.getPath(i);
                sprite.push_back(ofImage());
                sprite.back().loadImage(filePath);
            }
        }
    }
    else{
        sd->name = "char_B";
        
        ofDirectory dir;
        int nFiles = dir.listDir("sprites/boy");
        if (nFiles) {
            for (int i= 0; i<dir.numFiles(); i++) {
                string filePath = dir.getPath(i);
                sprite.push_back(ofImage());
                sprite.back().loadImage(filePath);
            }
        }
    }
 
    
    character.body->SetFixedRotation(true);
    character.body->SetLinearDamping(0.5);
    
    adjustedHeight = 85;
}
示例#6
0
void imageLoader::loadDir(){


    if(!dir.isDirectoryEmpty(path)){
        int imgSize = images.size();
        dir.listDir(path);
        if(dir.size() > imgSize || dir.size() < imgSize) {
            //dir.sort(); // in linux the file system doesn't return file lists ordered in alphabetical order

            //allocate the vector to have as many ofImages as files
            if( dir.size() ){
                images.assign(dir.size(), ofImage());
            }

            // you can now iterate through the files and load them into the ofImage vector
            for(int i = 0; i < (int)dir.size(); i++){
                images[i].loadImage(dir.getPath(i));
            }
            help = false;
        }
    } else {
        help = true;
    }

}
void ImageShapeObject::listAllImages() {
    
    dir.listDir(filePath); // @todo move to constant
    dir.sort();
    
    // if directory is not empty, assign memory in vector
    // @todo check for dot files
    
    int newSize = (int)dir.size();
    
    if(newSize > 0) {
        images.assign(newSize, ofImage());
        
        // load each movie and set to first frame for display
        for(int i = 0; i < newSize; i++) {
            
            images.resize(newSize);
            loadedImagesPaths.resize(newSize);
            loadedImagesFilenames.resize(newSize);
            
            cout << "== Loading new Image " << dir.getPath(i) << endl;
            images[i].loadImage(dir.getPath(i));
            loadedImagesPaths[i] = dir.getPath(i);
            loadedImagesFilenames[i] = dir.getName(i);
        }
    }
}
示例#8
0
文件: ofApp.cpp 项目: jngrt/ofTMXTest
//--------------------------------------------------------------
void ofApp::setup(){
    ofBackground(100);
    ofSetColor(255);
    
    //Load TMX file
    ofBuffer buffer = ofBufferFromFile("example.tmx");
    map->ParseText(buffer.getText());

    //Check error
    if (map->HasError()) {
		printf("error code: %d\n", map->GetErrorCode());
		printf("error text: %s\n", map->GetErrorText().c_str());
		system("PAUSE");
        
		return map->GetErrorCode();
	}
    
    //Debug info
    printDebugInfo();
    
    //Load images
    for (int i = 0; i < map->GetNumTilesets(); ++i) {
        //tileSheet.loadImage("tmw_desert_spacing.png");
        tileSheets.push_back(ofImage());
        (tileSheets.back()).loadImage( map->GetTileset(i)->GetImage()->GetSource().c_str() );
    }
    
    
}
//--------------------------------------------------------------
void drPLayHitAreaImage::reset(){
    
    if (isReset == true) {
            menuMode = 0;
            testMenuMode = menuMode;
            //Directory-Image-------_
            dirDialogImageStringDefault = "record/media/images/";
            dirDialogImageString = dirDialogImageStringDefault;
            setDirirDialogImageString = "recPlaySmall_0";
            dirDialogImageString += setDirirDialogImageString;
            dirDialogImageString += "/";
            dirDialogImage.listDir(dirDialogImageString);
            dirDialogImage.sort();
            
            if(dirDialogImage.size()){
                images.assign(dirDialogImage.size(), ofImage());
            }
            
            for(int i = 0; i < (int)dirDialogImage.size(); i++){
                images[i].loadImage(dirDialogImage.getPath(i));
                if (i < MAX_NUM_IMAGE) {
                    myImage[i] = images[i];
                }
            }
            cout << " I DID " << endl;
        }

        isReset = false;
    }
示例#10
0
//--------------------------------------------------------------
void ofApp::setup(){
    grabber.setup(500, 500);
    ofSetRectMode(OF_RECTMODE_CENTER);
    
    img = ofImage();
    img.load("church.jpg");
    int w = img.getWidth();
    int h = img.getHeight();
    float aspect = w/ ((float)h);
//    if(w > h) img.resize(500, 500 * aspect);
//    else img.resize(500 / aspect, 500 );
    img.resize(500, 500);
    incBy = 10;
    
    for(int i = 0; i < img.getWidth(); i+=incBy) {
        for(int j = 0; j < img.getHeight(); j+=incBy) {
            ofImage tmpImg;
            tmpImg.clone(img);
            tmpImg.crop(i, j, incBy, incBy);
            images.push_back(tmpImg);
        }
    }
//    ofSort(images, sortOnBrightness);
    
    for(auto& img : images) {
        brightness.push_back(getAvgBrightness(img));
        colors.push_back(getAvgColor(img));
    }
    
}
示例#11
0
void Petal::setup(){
    rot.set( 0, 0, 0 );
    rotInc.set( ofRandom(-rotMult, rotMult), ofRandom(-rotMult, rotMult), ofRandom(-rotMult, rotMult) );
    petalSize=ofRandom(20,55);
    damping=0.98;
    setPicture=int(ofRandom(4));
    float phi = ofRandom( 0, TWO_PI );
    float costheta = ofRandom( -1.0f, 1.0f );
    
    float rho = sqrt( 1.0f - costheta * costheta ); //0~1, unsigned
    float x = rho * cos( phi );
    float y = rho * sin( phi );
    float z = costheta;//-1~1
    
    ofVec3f randVec(x, y, z);
    
    pos = randVec * ofRandom( 100.0f, 600.0f );
    vel = -randVec;

    for (int i=0; i<4; i++) {
        string result = "";
        stringstream currentCombo;
        currentCombo << i;
        result = currentCombo.str();
        petalList.push_back(ofImage());
        petalList[i].loadImage(ofToDataPath(result + ".png"));
       
}
}
示例#12
0
	//----------
	void Register::traverseDirectoryImages(string dataPath, vector<string> outputNamespace) {
		if (ofDirectory::doesDirectoryExist(dataPath)) {
			ofDirectory files;
			files.listDir(dataPath);
			for (int i = 0; i<files.size(); i++) {
				const auto filename = files.getPath(i);
				auto outputName = ofFilePath::getBaseName(filename); 
				
				//check if it's a subfolder
				if (ofDirectory(filename).isDirectory()) {
					auto innerNamespace = outputNamespace;
					innerNamespace.push_back(outputName);
					this->traverseDirectoryImages(dataPath + "/" + outputName, innerNamespace);
				}

				//if not, check whether it has the right extension
				const auto extension = ofFilePath::getFileExt(filename);
				if (!(extension == "png" || extension == "jpeg" || extension == "jpg")) {
					continue;
				}

				//transform the output name to include namespace
				transformName(outputName, outputNamespace);

				//insert and load the image
				if (this->images.find(outputName) != this->images.end()) {
					continue;
				}
				this->images.insert(pair<string, ofImage>(outputName, ofImage()));
				this->images[outputName].loadImage(filename);

				ofLogNotice("ofxAssets") << "Loaded image asset '" << outputName << "'" << endl;
			}
		}
	}
//--------------------------------------------------------------
void threadedScanLoader::setup(int maxNumFramesIn, int resizeToW, int resizeToH){
	maxNumFrames	= maxNumFramesIn;
	totalNumFrames	= 0;
	
	resizeW		 = resizeToW;
	resizeH		 = resizeToH;
	
	depthImageFrames.assign(maxNumFrames, ofImage());
}
示例#14
0
void testApp::loadSet(int set){
    
    int total= animationRefs[set].y-animationRefs[set].x;
    for(vector<string>::iterator it = imagePaths.begin()+animationRefs[set].x; it != imagePaths.begin()+animationRefs[set].y; ++it){
                        images.push_back(ofImage());
                       images.back().loadImage(*it);
    }
      animationsLoaded[set]=true;
    
    
}
示例#15
0
RainScene::RainScene(vector<Particle*>* people, vector<Particle*>* hands)
: IScene(people, hands)
{

	int screenW = ofGetWidth();
	int screenH = ofGetHeight();

	//create rain particles
	m_rainParticles = new Particle[s_numRainParticles];
	for (int i = 0; i < s_numRainParticles; ++i)
	{
		m_rainParticles[i] = Particle(ofVec2f(ofRandom(0, screenW), ofRandom(0, screenH)));
		m_rainParticles[i].vel = ofVec2f(0.f, ofRandom(screenH * 0.005f, screenH * 0.01f));
		m_rainParticles[i].maxSpeed = m_rainParticles[i].vel.length();
	}

	float scale = screenH * screenW;
	float particleSize = sqrt(scale) / 50.f;

	//create vector field
	m_rainFieldWidth = ofGetWidth() / s_vectorFieldDensity;
	m_rainFieldHeight = ofGetHeight() / s_vectorFieldDensity;
	m_rainVectorField = new Particle[m_rainFieldWidth * m_rainFieldHeight];
	m_rainVectorFieldNorm = m_rainFieldWidth * 0.01f;

	int count = 0;

	for (int i = 0; i < m_rainFieldWidth; ++i)
	{
		for (int j = 0; j < m_rainFieldHeight; ++j)
		{
			int pos = (i*m_rainFieldHeight) + j;
			m_rainVectorField[pos] = Particle(ofVec3f(i * s_vectorFieldDensity, j * s_vectorFieldDensity));
			m_rainVectorField[pos].vel = ofVec3f(m_rainVectorFieldNorm, 0.f);
			m_rainVectorField[pos].maxSpeed = s_vectorFieldDensity;
		}
	}

	m_rainImage = ofImage("RainScene/Rain2.png");
	m_rainBackground = ofImage("RainScene/RainBackground.png");
}
示例#16
0
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo info){
	
	if( info.files.size() > 0 ){
		dragPt = info.position;
		
		draggedImages.assign( info.files.size(), ofImage() );
		for(int k = 0; k < info.files.size(); k++){
			draggedImages[k].loadImage(info.files[k]);
		}
	}

}
示例#17
0
void ofApp::setup() {
  inputDrawImage = ofImage();
  outputDrawImage = ofImage();

  inputFrames = new FrameSequence();
  inputFrames->loadFrames("nuclearexplosion/out", 300);

  outputFrames = inputFrames->clone();

  //pixelBlurrer = new TemporalPixelBlurrer(outputFrames, 5);
  pixelSorter = new TemporalPixelSorter(outputFrames);
  //pixelSorter->sort();
  //pixelSorter->updatePixels();

  inputChart = new ColorBarChart();
  outputChart = new ColorBarChart();

  setBarChart(308, 118);

  hudFont.loadFont("verdana.ttf", 9);
  screenshotNamer.init("screenies/screenie", "png");
}
示例#18
0
	//----------
	void Decoder::savePreviews() {
		string filename = data.getFilename();
		if (filename == "") {
			filename = ofSystemSaveDialog("DataSet", "Select output path for previews").getPath();
		}

		if (projectorInCamera.isAllocated()) {
			projectorInCamera.save(filename + "-projectorInCamera.png");
		}

		if (cameraInProjector.isAllocated()) {
			cameraInProjector.save(filename + "-cameraInProjector.png");
		}

		if (data.getMedian().isAllocated()) {
			ofImage(data.getMedian()).save(filename + "-median.png");
		}

		if (data.getMedianInverse().isAllocated()) {
			ofImage(data.getMedianInverse()).save(filename + "-medianInverse.png");
		}
	}
示例#19
0
//--------------------------------------------------------------
void testApp::setup() {
    
	tess.setup();
    tess.setInputName(""); //("tessdata/eng.traineddata");
	tess.setWhitelist("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,");
	tess.setAccuracy(ofxTesseract::ACCURATE);
	tess.setMode(ofxTesseract::AUTO);
    
    
    mov.loadMovie("paradise.pdf");
    mov.setSpeed(0.1);
    mov.play();
    mov.setPaused(true);
    mov.setFrame(0);
    
    img = ofImage(mov.getPixelsRef());
    scaled = ofImage(mov.getPixelsRef());
    
    scale = 1.0;
    medianSize = 1;
    
    printf("total frames %i\n", mov.getTotalNumFrames());
    
    //ofSetBackgroundAuto(false);
    ofSetFrameRate(30);
    
    int totalPages = mov.getTotalNumFrames();
    
    gui = new ofxUICanvas(0,0,320,320);		//ofxUICanvas(float x, float y, float width, float height)		
    gui->addWidgetDown(new ofxUILabel("PDF OCR", OFX_UI_FONT_LARGE)); 
    gui->addWidgetDown(new ofxUISlider(304,32,0,totalPages,0,"FRAME"));
    gui->addWidgetDown(new ofxUIButton(64, 64, false, "RUN_OCR"));  
    gui->addWidgetDown(new ofxUISlider(304,32,0,10,1.0,"SCALE_AMT"));
    gui->addWidgetDown(new ofxUISlider(304,32,1,100,1.0,"BLUR_AMT")); 
    ofAddListener(gui->newGUIEvent, this, &testApp::guiEvent); 
    gui->loadSettings("GUI/guiSettings.xml"); 
    
}
示例#20
0
//--------------------------------------------------------------
void testApp::setup(){
    ofSetWindowTitle("Pattern Uploader for Brother Knitting machines");
    ofSetVerticalSync(true); 
	ofEnableSmoothing(); 
    // format
    
    file=NULL;
    dragPt.x = 100;
    dragPt.y = 100;
    
    font.loadFont("GUI/NewMedia Fett.ttf",14);
    
    //"/dev/tty.usbserial-A7V8PMWN
    myKnittingMachine.setup();
    
    red = 233; blue = 27; green = 52; 
	
	float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; 
    float length = 320;
    float w = length - 2 * xInit;
    float h = 32;
    drawPadding = false; 

    
    // Settings
    gui_settings = new ofxUICanvas(ofGetWidth()-length,0,length+xInit,ofGetHeight());
   
    
    gui_settings->addWidgetDown(new ofxUILabel("KNITTING MACHINE ACTIONS:", OFX_UI_FONT_MEDIUM));
    gui_settings->addWidgetDown(new ofxUISpacer(w, 2));
    gui_settings->addWidgetDown(new ofxUILabelButton("Clear patterns", false, w, h, OFX_UI_FONT_MEDIUM));
    uploadLabelToggle = new ofxUILabelToggle("Start Knitting", false, w, h, OFX_UI_FONT_MEDIUM);
    gui_settings->addWidgetDown(uploadLabelToggle);
    
    gui_settings->addWidgetDown(new ofxUISpacer(length-xInit, 2));
    // ofxUILabelButton(string _name, bool _value, float w = 0, float h = 0, float x = 0, float y = 0, int _size = OFX_UI_FONT_MEDIUM)
    
    gui_settings->addWidgetDown(new ofxUILabelButton("Refresh serial port", false, w, h));
    
    //ofxUIRadio(string _name, vector<string> names, int _orientation, float w, float h, float x = 0, float y = 0)
    
    serialPortRadio = new ofxUIRadio( "Select serial port:", myKnittingMachine.getListSerialDevices(), OFX_UI_ORIENTATION_VERTICAL, h/2, h/2);
    gui_settings->addWidgetDown(serialPortRadio); 
    gui_settings->addWidgetDown(new ofxUISpacer(length-xInit, 2)); 
    
    gui_settings->loadSettings("GUI/guiSettings_settings.xml");
    ofAddListener(gui_settings->newGUIEvent,this,&testApp::guiEvent);
    
     draggedImages.push_back(ofImage());
}
示例#21
0
void Resource::loadFolder(const char * folderName) {
	ofDirectory dir;
	dir.open(ofToDataPath(folderName, true));
	dir.listDir();
	
	for (auto& file : dir.getFiles()) {
		if (file.getExtension() == "png") {
			images.insert(decltype(images)::value_type(file.getFileName(), ofImage()))
				.first->second.loadImage(file.path());
		} else if (file.getExtension() == "wav") {
			sounds.insert(decltype(sounds)::value_type(file.getFileName(), ofSoundPlayer()))
			.first->second.loadSound(file.path());
		}
	}
	
	dir.close();
}
示例#22
0
//--------------------------------------------------------------
void testApp::setup(){

	dir.listDir("images/of_logos/");

	//allocate the vector to have as many ofImages as files
	if( dir.size() ){
		images.assign(dir.size(), ofImage());
	}

	// you can now iterate through the files and load them into the ofImage vector
	for(int i = 0; i < dir.size(); i++){
		images[i].loadImage(dir.getPath(i));
	}
	currentImage = 0;

	ofBackground(ofColor::white);
}
示例#23
0
ofImage ofxDarknet::nightmare( ofPixels & pix, int max_layer, int range, int norm, int rounds, int iters, int octaves, float rate, float thresh )
{
	image im = convert( pix );

	for( int e = 0; e < rounds; ++e ) {
		fprintf( stderr, "Iteration: " );
		fflush( stderr );
		for( int n = 0; n < iters; ++n ) {
			fprintf( stderr, "%d, ", n );
			fflush( stderr );
			int layer = max_layer + rand() % range - range / 2;
			int octave = rand() % octaves;
			optimize_picture( &net, im, layer, 1 / pow( 1.33333333, octave ), rate, thresh, norm );
		}
	}
	return ofImage( convert( im ) );
}
示例#24
0
//--------------------------------------------------------------
void testApp::setup() {
    
    ofBackground(0);
    ofSetWindowTitle("The Moon is made of plops");
                     
    // read the directory for the images
    // we know that they are named in seq
    // 读取路径中的图片
    // 我们知道这些图片都是按照顺序命名的
    ofDirectory dir;
    
    int nFiles = dir.listDir("plops");
    if(nFiles) {
        
        for(int i=0; i<dir.numFiles(); i++) { 
            
            // add the image to the vector
            string filePath = dir.getPath(i);
            images.push_back(ofImage());
            images.back().loadImage(filePath);
            
        }
        
    } 
    else printf("Could not find folder\n");
    
    // this toggle will tell the sequence
    // be be indepent of the app fps
    
    // 这个切换会告诉序列每一桢都单独播放
    bFrameIndependent = true;
    
    // this will set the speed to play 
    // the animation back we set the
    // default to 24fps
    //这里将会设置播放动画的的速度
    //默认值是24fps
    sequenceFPS = 24;

    // set the app fps
    //设置应用的fps
    appFPS = 60;
    ofSetFrameRate(appFPS);
    
}
//--------------------------------------------------------------
void drPLayHitAreaImage::setup(){
    //Directory-Image-------_
    dirDialogImageStringDefault = "record/media/images/";
    dirDialogImageString = dirDialogImageStringDefault;
    setDirirDialogImageString = "recPlaySmall_1";
    dirDialogImageString += setDirirDialogImageString;
    dirDialogImageString += "/";
    dirDialogImage.listDir(dirDialogImageString);
	dirDialogImage.sort();
    
	if(dirDialogImage.size()){
		images.assign(dirDialogImage.size(), ofImage());
	}
    
	for(int i = 0; i < (int)dirDialogImage.size(); i++){
		images[i].loadImage(dirDialogImage.getPath(i));
        if (i < MAX_NUM_IMAGE) {
            myImage[i] = images[i];
        }
	}
    
    //playbackHitAreaImage-------------_
    isAddHitDialog = true;
    playbackHitAreaImage_0.setup();
    playbackHitAreaImage_0.setPosition(11, 500);
    playbackHitAreaImage_0.setDimensions();
    playbackHitAreaImage_0.setImage(myImage);
    //-------playbackHitAreaImage------_
    
    currentDialogImage = 0;
    setRecordImageFolderTest = dirDialogImageString;
    //----Directory-Image---_
    
    newBoundingBoxHeight =  playbackHitAreaImage_0.boundingBoxHeight/2;
    width = ofGetWidth();
    height = 0;
    setX_0 = (width/2)-(playbackHitAreaImage_0.allSize/2);
    //cout << setX_0 << endl;
    setY_0 = newBoundingBoxHeight;// - height/2;
    setX_1 = width/2 - playbackHitAreaImage_0.allSize/2;
    setY_1 = height + playbackHitAreaImage_0.boundingBoxHeight+5;
    
    menuMode = 0;
    testMenuMode = -1;
}
示例#26
0
//--------------------------------------------------------------
void ofApp::setup() {

    dir.listDir("images/of_logos/");
    dir.sort(); // in linux the file system doesn't return file lists ordered in alphabetical order

    //allocate the vector to have as many ofImages as files
    if( dir.size() ) {
        images.assign(dir.size(), ofImage());
    }

    // you can now iterate through the files and load them into the ofImage vector
    for(int i = 0; i < (int)dir.size(); i++) {
        images[i].load(dir.getPath(i));
    }
    currentImage = 0;

    ofBackground(ofColor::white);
}
//--------------------------------------------------------------
void ofxVisualPopupManager::setup(){
    
    
    if (_scenarioIndex == COMIC_STRIP) {
        images.clear();
        images.push_back(new ofxVisualPopup("comic/img/shebam.jpg", false, 0, true));
        images.push_back(new ofxVisualPopup("comic/img/pow.jpg", false, 0, true));
        images.push_back(new ofxVisualPopup("comic/img/blop.jpg", false, 0, true));
        images.push_back( new ofxVisualPopup("comic/img/wizz.jpg", false, 0, true));
        
        imgCol.clear();
        imgCol.push_back(ofImage("comic/buildings/b1.png"));
        imgCol.push_back(ofImage("comic/buildings/b2.png"));
        imgCol.push_back(ofImage("comic/buildings/b3.png"));
        imgCol.push_back(ofImage("comic/buildings/b4.png"));
        imgCol.push_back(ofImage("comic/buildings/b5.png"));
        imgCol.push_back(ofImage("comic/buildings/b6.png"));
        imgCol.push_back(ofImage("comic/buildings/b7.png"));
        imgCol.push_back(ofImage("comic/buildings/b8.png"));
        imgPos.clear();
        imgSize.clear();
        
    }
    else if (_scenarioIndex == MOULINEX) {
        images.clear();
        images.push_back(new ofxVisualPopup("vid/MixPub.mp4", true, 0, false));
    }
	else if (_scenarioIndex == SUPERMARKETLADY) {
		images.clear();
		images.push_back(new ofxVisualPopup("comic/img/supermarketlady.jpg", false, 0, false));
	} else if (_scenarioIndex == BONBONS) {
		images.clear();
		images.push_back(new ofxVisualPopup("vid/stripes1.mp4", true, 0, true));
		images.push_back(new ofxVisualPopup("vid/stripes2.mp4", true, 0, true));
		images.push_back(new ofxVisualPopup("vid/stripes3.mp4", true, 0, true));
	}

	
    imgIndex = -1;
	
}
void ofApp::initRandom(ofFbo &target, int seed){
    printf("init random %d\n", seed);
    ofSeedRandom(seed);
    ofFloatPixels newState;
    int w = target.getWidth();
    int h = target.getHeight();
    newState.allocate(w, h, OF_PIXELS_RGB);
    for(int x=0; x<w; x++){
        for(int y=0; y<h; y++){
            float r = ofSignedNoise(x,y,frame);
            float g = ofSignedNoise(x+11111,y+11111,frame);
            float b = ofSignedNoise(x+37283,y+37283,frame);
            newState.setColor(x,y,ofFloatColor(r,g,b));
        }
    }
    target.begin();
    ofImage(newState).draw(0,0,w,h);
    target.end();
}
示例#29
0
//--------------------------------------------------------------
void ofApp::setup(){

	angle = 0;
	oneShot = false;
	pdfRendering = false;

	ofBackground(225,225,225);
	ofSetVerticalSync(true);
	
	font.loadFont("frabk.ttf", 24, true, false, true);
	
	dropZoneRects.assign(3, ofRectangle());

	images.assign(3, ofImage());
	images[0].loadImage("DSC09316.jpeg");
	
	for(unsigned int k = 0; k < dropZoneRects.size(); k++){
		dropZoneRects[k] = ofRectangle(32 + k * 310, 200, 300, 200);
	}
}
示例#30
0
文件: ofApp.cpp 项目: CamZHU/ofxTSNE
//--------------------------------------------------------------
void ofApp::setup(){
    
    // load all the images
    ofLog() << "Gathering images...";
    ofDirectory dir;
    int nFiles = dir.listDir(ofToDataPath("images/"));
    if(nFiles) {
        for(int i=0; i<dir.size(); i++) {
            if (i % 20 == 0)    ofLog() << " - loading image "<<i<<" / "<<dir.size();
            string filePath = dir.getPath(i);
            images.push_back(ofImage());
            images.back().load(filePath);
        }
    }
    
    // setup ofxCcv
    ccv.setup("image-net-2012.sqlite3");
    
    // encode all of the images with ofxCcv
    ofLog() << "Encoding images...";
    for (int i=0; i<images.size(); i++) {
        if (i % 20 == 0)    ofLog() << " - encoding image "<<i<<" / "<<images.size();
        vector<float> encoding = ccv.encode(images[i], ccv.numLayers()-1);
        encodings.push_back(encoding);
    }
    
    // run t-SNE and load image points to imagePoints
    ofLog() << "Run t-SNE on images";
    imagePoints = tsne.run(encodings, 2, 25, 0.1, true);
    
    // make the images the same size
    for (int i=0; i<images.size(); i++) {
        images[i].resize(100 * images[i].getWidth() / images[i].getHeight(), 100);
    }
    
    // setup gui
    gui.setup();
    gui.add(scale.set("scale", 4.0, 0.0, 10.0));
    gui.add(imageSize.set("imageSize", 1.0, 0.0, 2.0));
}