Example #1
0
void Quad::updateGrid(float dt)
{
	//if (xDivs == 0 && yDivs == 0) return;
	if (!doUpdateGrid) return;

	if (gridType == GRID_WAVY)
	{
		gridTimer += dt * drawGridTimeMultiplier;
		resetGrid();
		int hx = xDivs/2;
		for (int x = 0; x < xDivs; x++)
		{
			float yoffset = x * drawGridOffsetY;
			float addY = 0;
			if (drawGridModY != 0)
				addY = cosf(gridTimer+yoffset)*drawGridModY;
			for (int y = 0; y < yDivs; y++)
			{
				float xoffset = y * drawGridOffsetX;
				if (drawGridModX != 0)
				{
					float addX = (sinf(gridTimer+xoffset)*drawGridModX);
					if (drawGridOut && x < hx)
						drawGrid[x][y].x += addX;
					else
						drawGrid[x][y].x -= addX;
				}
				drawGrid[x][y].y += addY;
			}
		}
	}
}
Example #2
0
void Quad::setGridPoints(bool vert, const std::vector<Vector> &points)
{
	if (!drawGrid) return;
	resetGrid();
	for (int i = 0; i < points.size(); i++)
	{
		if (!vert) // horz
		{
			for (int y = 0; y < yDivs; y++)
			{
				for (int x = 0; x < xDivs; x++)
				{
					if (x < points.size())
					{
						drawGrid[x][y] += points[x];
					}
				}
			}
		}
		else
		{
			for (int x = 0; x < xDivs; x++)
			{
				for (int y = 0; y < yDivs; y++)
				{
					if (y < points.size())
					{
						drawGrid[x][y] += points[y];
					}
				}
			}
		}
	}
}
Example #3
0
/*
 * ---------------------------------------------------------
 * Setups
 * ---------------------------------------------------------
 */
void MainWindow::createWindow() {


    QWidget *w = new QWidget;
    setCentralWidget(w);

    _playBox = new PlayBox(this);

    _tracklist = new Tracklist(this);
    _playlist = new Playlist(_tracklist, this);
    _colourMapDisplay = new ColourMapDisplay(this);


    _display = new GridDisplay(600, _tracklist, _dataGrid, this);

    QGridLayout *gridLayout = new QGridLayout;
    //fromRow, fromCol, rowSpan, colSpan
    gridLayout->addWidget(	_display,			0, 0, 4, 1);

    QVBoxLayout *vbox = new QVBoxLayout;
    vbox->addWidget(new QLabel(tr("Playlists")));
    vbox->addWidget(_playlist);
    vbox->addWidget(new QLabel(tr("Track list")));
    vbox->addWidget(_tracklist);
    vbox->addWidget(_colourMapDisplay);
    gridLayout->addLayout(vbox,1,1,1,1);

    connect(_display, SIGNAL(playingTrack(MusicTrack*)),
            this, SLOT(updateCurrentlyPlaying(MusicTrack*)));

    connect(this, SIGNAL(libraryUpdated()), _playlist, SLOT(updatePlaylist()));
    connect(this, SIGNAL(libraryUpdated()), _display, SLOT(reload()));
    connect(this, SIGNAL(openPredictGridFile(QString)), _display, SLOT(openPredictionGrid(QString)));
    connect(this, SIGNAL(savePredictGridFile(QString)), _display, SLOT(savePredictionGrid(QString)));
    connect(this, SIGNAL(playModeChanged()), _display, SLOT(playModeChanged()));
    connect(this, SIGNAL(cancelButtonSignal()), _display, SLOT(cancelButton()));
    connect(_display, SIGNAL(fullScreenMode(bool)), this, SLOT(fullScreenMode(bool)));
    connect(this, SIGNAL(fullScreenModeOff()), _display, SLOT(fullScreenMouse()));
    connect(_playlist, SIGNAL(SelectedPlaylist(QString)), _display, SLOT(playlistSelected(QString)));
    connect(_display, SIGNAL(updateColourMap(int *, int)), _colourMapDisplay, SLOT(updateSquare(int *, int)));
    connect(this, SIGNAL(resetGrid()), _display, SLOT(resetGrid()));

    w->setLayout(gridLayout);
    statusBar()->showMessage(tr("Ready"));
}
Example #4
0
void Document::setSize(const QSize &size)
{
  if (size_ == size)
    return;

  size_ = size;

  resetGrid();
}
void
Grid::openPredictionGrid(QString fname)
{
    fstream file_ip((fname.toStdString()).c_str(), ios::in);
    if (!file_ip) {
        cerr << "Can't open input file " << endl;
        return;
    }

    int x_size = 0;
    int y_size = 0;
    int index = 0;
    int splitIndex = 0;
    QString qFname = "";
    string intBufferStr = "";
    string line = "";
    string listFname = "";
    string vecIndex = "";

    cout << "doing file stuff" << endl;

    // get the stored size of the vector
    getline(file_ip,intBufferStr);
    istringstream intBuffer(intBufferStr);
    intBuffer >> x_size;

    getline(file_ip, intBufferStr);
    istringstream intBufferTwo(intBufferStr);
    intBufferTwo >> y_size;

    cout << "x_size = " << x_size << endl;
    cout << "y_size = " << y_size << endl;

    cout << "Before reset grid" << endl;
    resetGrid();
    cout << "After reset grid" << endl;

    int i = 1;
    while(!file_ip.eof())
    {
        getline(file_ip,line);
        cout << "Line is " << line << endl;

        splitIndex = line.find_first_of(',');
        vecIndex = line.substr(0,splitIndex);
        listFname = line.substr(splitIndex + 1);
        qFname =  listFname.c_str();
        istringstream buffer(vecIndex);
        buffer >> index;
        cout << "index = " << index << endl;
        cout << "filename = " << qFname << endl;

        addTrack(index % som_height, index / som_height, qFname);
    }
}
Example #6
0
void
AnimatorScene::setGridLinesCount (int nGridLines)
{
  m_nGridLines = nGridLines;
  bool showGrid = m_showGrid;
  resetGrid ();
  m_showGrid = showGrid;
  if (m_showGrid)
    {
      addGrid ();
    }
  update ();
}
Example #7
0
void MainWindow::resetButtonPressed()
{
    QMessageBox msgBox;
    msgBox.setText("Are you sure you want to reset the grid?");
    msgBox.setInformativeText("You will need to extract and train your collection again.");
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::No);
    int ret = msgBox.exec();

    if(ret == QMessageBox::Yes)
    {
        emit resetGrid();
    }
}
Example #8
0
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();
}
Example #9
0
Document::Document(const QSize &size, QObject *parent)
    : QGraphicsScene(parent), size_(size)
{
  selection_ = NULL;
  floatingSelection_ = NULL;
  changed_ = false;

  editor_ = new Editor(this);
  map_ = new SparseMap(this);

  connect(editor_, SIGNAL(changed()), this, SLOT(documentChanged_()));

  grid_ = NULL;
  resetGrid();

  GlobalState::self()->undoGroup()->addStack(editor_);
}
Example #10
0
void Quad::createGrid(int xd, int yd)
{
	deleteGrid();
	
	xDivs = xd;
	yDivs = yd;
	
	drawGrid = new Vector * [xDivs];
	for (int i = 0; i < xDivs; i++)
	{
		drawGrid[i] = new Vector [yDivs];
		for (int j = 0; j < yDivs; j++)
		{
			drawGrid[i][j].z = 1;
		}
	}
	
	resetGrid();
}
void main() {
	char myGrid[NRows][NCols];

	/****** 16.216 PROGRAM 8 ******
		ADD ADDITIONAL VARIABLES HERE
	********************************/	

	resetGrid(myGrid);			// Initialize grid to clear state

	/******* 16.216 PROGRAM 8 *******
		LOOP TO REPEATEDLY PROMPT FOR AND EXECUTE INPUT COMMANDS
	*********************************/

		/***** 16.216 PROGRAM 8 *******
			PROMPT FOR AND READ INPUT COMMAND 
		*******************************/
		
		/***** 16.216 PROGRAM 8 *******
			"print" COMMAND ENTERED--PRINT CURRENT STATE OF GRID 
		*******************************/
		
		/***** 16.216 PROGRAM 8 *********
			"reset" COMMAND ENTERED--RESET GRID TO HAVE NO BOXES 
		*********************************/
		
		/***** 16.216 PROGRAM 8 *********
			"add" COMMAND ENTERED--PROMPT FOR ORIGIN 
			COORDINATES (X,Y), WIDTH, AND HEIGHT, THEN
			ADD BOX TO GRID
		**********************************/

		/***** 16.216 PROGRAM 8 *********
			"exit" COMMAND ENTERED--END PROGRAM 
		**********************************/

		/***** 16.216 PROGRAM 8 *********
			NO MATCHING COMMAND--PRINT ERROR 
		*********************************/
		
	/***** 16.216 PROGRAM 8 ********
		END LOOP
	********************************/
}
Example #12
0
void BoggleSolver::setGrid(const std::string& g)
{
  std::vector<char> tmp;
  for(std::string::const_iterator it = g.begin(); it != g.end();++it)
  {
    if(*it != ' ')
    {
      if( *it != ',')
	tmp.push_back((char)toupper(*it));
      else
      {
	grid.push_back(tmp);
	tmp.clear();
      }
    }
  }
  grid.push_back(tmp);
  if(!checkGridIntegrity())
  {
      std::cerr << "Invalid Grid" << std::endl;
      resetGrid();
  }
}
Example #13
0
void AfterEffectManager::clear()
{
	deleteEffects();
	resetGrid();
}
Example #14
0
MStatus ProxyViz::compute( const MPlug& plug, MDataBlock& block )
{
	if(!m_enableCompute) return MS::kSuccess;
	if( plug == outValue ) {
		
		updateWorldSpace(thisMObject() );
		
		MStatus status;

		ExampVox * defBox = plantExample(0);
		
		defBox->setGeomSizeMult(block.inputValue(aradiusMult).asFloat() );
		
		defBox->setGeomBox(block.inputValue(abboxminx).asFloat(),
			block.inputValue(abboxminy).asFloat(), 
			block.inputValue(abboxminz).asFloat(), 
			block.inputValue(abboxmaxx).asFloat(), 
			block.inputValue(abboxmaxy).asFloat(), 
			block.inputValue(abboxmaxz).asFloat());
		
		float grdsz = defBox->geomExtent() * 32.f ;
		if(grdsz < 32.f) {
			AHelper::Info<float>(" ProxyViz input box is too small", grdsz);
			grdsz = 32.f;
			AHelper::Info<float>(" trancated to", grdsz);
		}
		
		if(m_toSetGrid) {
			m_toSetGrid = false;
			resetGrid(grdsz);
		}
		
		if(_firstLoad) {
/// internal cache only, initializing from external cache is obsolete 
			if(!loadInternal(block) )
				std::cout<<"\n ERROR proxviz cannot load internal cache";

			_firstLoad = 0;
		}
        
		if(!m_toCheckVisibility) {
			MArrayDataHandle groundMeshArray = block.inputArrayValue(agroundMesh );
			MArrayDataHandle groundSpaceArray = block.inputArrayValue(agroundSpace );
/// in case no ground is connected
            if(updateGround(groundMeshArray, groundSpaceArray )) {
                moveWithGround();
                AHelper::Info<std::string>(" ProxyViz ground ", groundBuildLog() );
            }
		}
		
		if(!m_hasParticle) {
			block.setClean(plug);
            return MS::kSuccess;
		}
		
		const int ngroups = block.inputValue(agroupcount).asInt();
		
		MDataHandle hdata = block.inputValue(outPositionPP, &status);
        MFnVectorArrayData farray(hdata.data(), &status);
        if(!status) {
            MGlobal::displayInfo("proxy viz is not properly connected to a particle system");
			block.setClean(plug);
            return MS::kSuccess;
        }
    
        MDataHandle scaledata = block.inputValue(outScalePP, &status);
        MFnVectorArrayData scalearray(scaledata.data(), &status);
        if(!status) {
            MGlobal::displayInfo("proxy viz is not properly connected to a particle system");
			block.setClean(plug);
            return MS::kSuccess;
        }
		
		MDataHandle rotatedata = block.inputValue(outRotationPP, &status);
        MFnVectorArrayData rotatearray(rotatedata.data(), &status);
        if(!status) {
            MGlobal::displayInfo("proxy viz is not properly connected to a particle system");
			block.setClean(plug);
            return MS::kSuccess;
        }
		
		MDataHandle replaceData = block.inputValue(outReplacePP, &status);
        MFnDoubleArrayData replaceArrayFn(replaceData.data(), &status);
        if(!status) {
            MGlobal::displayInfo("proxy viz is not properly connected to a particle system, needs userScalarPP");
			block.setClean(plug);
            return MS::kSuccess;
        }
		
		MVectorArray outPosArray = farray.array();	
        MVectorArray outScaleArray = scalearray.array();
		MVectorArray outRotateArray = rotatearray.array();
		MDoubleArray outReplaceArray = replaceArrayFn.array();
		
		if( outPosArray.length() < 1) {
			block.setClean(plug);
			return MS::kSuccess;
		}
		
		computePPAttribs(outPosArray, outRotateArray, outScaleArray, outReplaceArray,
						ngroups);

        float result = outPosArray.length();

		MDataHandle outputHandle = block.outputValue( outValue );
		outputHandle.set( result );
		block.setClean(plug);
    }
	if(plug == outValue1) {
		
		MArrayDataHandle hArray = block.inputArrayValue(ainexamp);
		updateExamples(hArray);

		float result = 91.f;

		MDataHandle outputHandle = block.outputValue( outValue1 );
		outputHandle.set( result );
		block.setClean(plug);
	}

	return MS::kSuccess;
}
Example #15
0
gameGrid::gameGrid(void)
{
	resetGrid();
}
Example #16
0
void Reprojector::reprojectMap(
    FramePtr frame,
    std::vector< std::pair<FramePtr,std::size_t> >& overlap_kfs)
{
  resetGrid();

  // Identify those Keyframes which share a common field of view.
  SVO_START_TIMER("reproject_kfs");
  list< pair<FramePtr,double> > close_kfs;
  map_.getCloseKeyframes(frame, close_kfs);

  // Sort KFs with overlap according to their closeness
  close_kfs.sort(boost::bind(&std::pair<FramePtr, double>::second, _1) <
                 boost::bind(&std::pair<FramePtr, double>::second, _2));

  // Reproject all mappoints of the closest N kfs with overlap. We only store
  // in which grid cell the points fall.
  size_t n = 0;
  overlap_kfs.reserve(options_.max_n_kfs);
  for(auto it_frame=close_kfs.begin(), ite_frame=close_kfs.end();
      it_frame!=ite_frame && n<options_.max_n_kfs; ++it_frame, ++n)
  {
    FramePtr ref_frame = it_frame->first;
    overlap_kfs.push_back(pair<FramePtr,size_t>(ref_frame,0));

    // Try to reproject each mappoint that the other KF observes
    for(auto it_ftr=ref_frame->fts_.begin(), ite_ftr=ref_frame->fts_.end();
        it_ftr!=ite_ftr; ++it_ftr)
    {
      // check if the feature has a mappoint assigned
      if((*it_ftr)->point == NULL)
        continue;

      // make sure we project a point only once
      if((*it_ftr)->point->last_projected_kf_id_ == frame->id_)
        continue;
      (*it_ftr)->point->last_projected_kf_id_ = frame->id_;
      if(reprojectPoint(frame, (*it_ftr)->point))
        overlap_kfs.back().second++;
    }
  }
  SVO_STOP_TIMER("reproject_kfs");

  // Now project all point candidates
  SVO_START_TIMER("reproject_candidates");
  {
    boost::unique_lock<boost::mutex> lock(map_.point_candidates_.mut_);
    auto it=map_.point_candidates_.candidates_.begin();
    while(it!=map_.point_candidates_.candidates_.end())
    {
      if(!reprojectPoint(frame, it->first))
      {
        it->first->n_failed_reproj_ += 3;
        if(it->first->n_failed_reproj_ > 30)
        {
          map_.point_candidates_.deleteCandidate(*it);
          it = map_.point_candidates_.candidates_.erase(it);
          continue;
        }
      }
      ++it;
    }
  } // unlock the mutex when out of scope
  SVO_STOP_TIMER("reproject_candidates");

  // Now we go through each grid cell and select one point to match.
  // At the end, we should have at maximum one reprojected point per cell.
  SVO_START_TIMER("feature_align");
  for(size_t i=0; i<grid_.cells.size(); ++i)
  {
    // we prefer good quality points over unkown quality (more likely to match)
    // and unknown quality over candidates (position not optimized)
    if(reprojectCell(*grid_.cells.at(grid_.cell_order[i]), frame))
      ++n_matches_;
    if(n_matches_ > (size_t) Config::maxFts())
      break;
  }
  SVO_STOP_TIMER("feature_align");
}