void TimeLineCells::mouseMoveEvent( QMouseEvent* event ) { if ( m_eType == TIMELINE_CELL_TYPE::Layers ) { endY = event->pos().y(); emit mouseMovedY( endY - startY ); } int frameNumber = getFrameNumber( event->pos().x() ); //int layerNumber = getLayerNumber( event->pos().y() ); if ( m_eType == TIMELINE_CELL_TYPE::Tracks ) { if ( timeLine->scrubbing ) { mEditor->scrubTo( frameNumber ); } else { if ( startLayerNumber != -1 && startLayerNumber < mEditor->object()->getLayerCount() ) { Layer *currentLayer = mEditor->object()->getLayer(startLayerNumber); // Did we move to another frame ? // if ( frameNumber != lastFrameNumber ) { // Check if the frame we clicked was selected // if ( canMoveFrame ) { // If it is the case, we move the selected frames in the layer // movingFrames = true; int offset = frameNumber - lastFrameNumber; currentLayer->moveSelectedFrames(offset); mEditor->updateCurrentFrame(); } else if ( canBoxSelect ){ // Otherwise, we do a box select // boxSelecting = true; currentLayer->deselectAll(); currentLayer->setFrameSelected(startFrameNumber, true); currentLayer->extendSelectionTo(frameNumber); } lastFrameNumber = frameNumber; } currentLayer->mouseMove( event, frameNumber ); } } } timeLine->update(); }
void TimeLineCells::mouseDoubleClickEvent( QMouseEvent* event ) { int frameNumber = getFrameNumber( event->pos().x() ); int layerNumber = getLayerNumber( event->pos().y() ); // -- short scrub -- if ( event->pos().y() < 20 ) { mPrefs->set(SETTING::SHORT_SCRUB, !shortScrub); } // -- layer -- Layer* layer = mEditor->object()->getLayer( layerNumber ); if ( layer ) { if ( m_eType == TIMELINE_CELL_TYPE::Tracks && ( layerNumber != -1 ) && ( frameNumber > 0 ) && layerNumber < mEditor->object()->getLayerCount() ) { mEditor->object()->getLayer( layerNumber )->mouseDoubleClick( event, frameNumber ); } else if ( m_eType == TIMELINE_CELL_TYPE::Layers ) { layer->editProperties(); update(); } } }
void RenderGlobals::getImageName() { double fn = getFrameNumber(); MCommonRenderSettingsData data; MRenderUtil::getCommonRenderSettings(data); MObject renderLayer = MFnRenderLayer::currentLayer(); MString ext = this->imageFormatString.toLowerCase(); ext = pystring::lower(ext.asChar()).c_str(); this->imageOutputFile = data.getImageName(data.kFullPathImage, fn, this->imageName, MString(""), ext, renderLayer); }
void GTVideo::setForegroundMask() { for (int i=0; i<getFrameNumber(); i++) { cv::Mat foreground_mask(source.at(0).rows,source.at(0).cols,CV_8UC1); subtractBackground(foreground_mask,source.at(i)); foregroundMask.push_back(foreground_mask); } //cv::imwrite("frame_cur.jpg",source.at(55)); //cv::imwrite("foregroundmask.jpg",foregroundMask.at(55)); }
void BaseFrameListStimulus::drawFrame(shared_ptr<StimulusDisplay> display) { int frameNumber = getFrameNumber(); int numFrames = getNumFrames(); if (frameNumber < numFrames) { auto stim = getStimulusForFrame(frameNumber); if (stim->isLoaded()) { stim->draw(display); } else { merror(M_DISPLAY_MESSAGE_DOMAIN, "Stimulus \"%s\" (frame number %d of stimulus \"%s\") is not loaded and will not be displayed", stim->getTag().c_str(), frameNumber, getTag().c_str()); } lastFrameDrawn = frameNumber; } }
Datum BaseFrameListStimulus::getCurrentAnnounceDrawData() { Datum announceData = StandardDynamicStimulus::getCurrentAnnounceDrawData(); if (stimulusGroup) { announceData.addElement(STIMULUS_GROUP, stimulusGroup->getTag()); } announceData.addElement(LOOP, loop->getValue()); announceData.addElement("playing", Datum(isPlaying())); int frameNumber = getFrameNumber(); announceData.addElement("current_frame", Datum((long)frameNumber)); Datum currentStimulusAnnounceData(0L); if ((frameNumber >= 0) && (frameNumber < getNumFrames())) { currentStimulusAnnounceData = getStimulusForFrame(frameNumber)->getCurrentAnnounceDrawData(); } announceData.addElement("current_stimulus", currentStimulusAnnounceData); return announceData; }
void VideoProcessor::run(){ cv::Mat frame; cv::Mat output; if (!isOpened()) // if no capture device has been set return; stop= false; while (!isStopped()) { if (!readNextFrame(frame)) // read next frame if any break; if (windowNameInput.length()!=0) // display input frame cv::imshow(windowNameInput,frame); if (callIt) { // calling the process function or method if (process){ // process the frame process(frame, output); } else if (frameProcessor){ frameProcessor->process(frame,output); } fnumber++; // increment frame number } else { output= frame; } if (outputFile.length()!=0) writeNextFrame(output); if (windowNameOutput.length()!=0) // display output frame cv::imshow(windowNameOutput,output); if (delay>=0 && cv::waitKey(delay)>=0) // introduce a delay stopIt(); if (frameToStop>=0 && getFrameNumber()==frameToStop)// check if we should stop stopIt(); } }
/* * To perform 1-D view interpolation * * \Output: * All the color images below are in 444, depth images are 400 * \param pSynYuvBuffer * To store the synthesis result. * \member m_pSynColorLeft * To store the synthesis color component from left ref w/o hole filling * \member m_pSynColorRight * To store the synthesis color component from right ref w/o hole filling * \member m_pSynDepthLeft * To store the synthesis depth component from left ref w/o hole filling * \member m_pSynDepthRight * To store the synthesis depth component from right ref w/o hole filling * * Return: * true: if succeed; * false: if fails. */ bool CViewInterpolation::xViewInterpolation1DMode( CIYuv* pSynYuvBuffer ) { BYTE* RefLeft = m_pcImageLeft->getBuffer(); BYTE* RefRight = m_pcImageRight->getBuffer(); BYTE* RefDepthLeft = m_pcDepthMapLeft->getBuffer(); BYTE* RefDepthRight = m_pcDepthMapRight->getBuffer(); m_pViewSynthesis1D->SetFrameNumber( getFrameNumber()); //Zhejiang if ( 0 != m_pViewSynthesis1D->DoOneFrame(RefLeft, RefRight, RefDepthLeft, RefDepthRight, pSynYuvBuffer->getBuffer()) ) return false; if (getBoundaryNoiseRemoval()) { CIYuv pRefLeft; CIYuv pRefRight; CIYuv pRefDepthLeft; CIYuv pRefDepthRight; CIYuv pRefHoleLeft; CIYuv pRefHoleRight; int Width = m_pViewSynthesis1D->GetWidth(); int Height = m_pViewSynthesis1D->GetHeight(); int SampleFactor = m_pViewSynthesis1D->GetSubPelOption() * m_pViewSynthesis1D->GetUpsampleRefs(); m_pBoundaryNoiseRemoval->SetViewBlending(m_uiViewBlending); m_pBoundaryNoiseRemoval->SetColorSpace(m_uiColorSpace); m_pBoundaryNoiseRemoval->SetPrecision(SampleFactor); if(!pRefLeft.Resize(Height, Width*SampleFactor, 444)) return false; if(!pRefRight.Resize(Height, Width*SampleFactor, 444)) return false; if(!pRefDepthLeft.Resize(Height, Width*SampleFactor, 400)) return false; if(!pRefDepthRight.Resize(Height, Width*SampleFactor, 400)) return false; if(!pRefHoleLeft.Resize(Height, Width*SampleFactor, 400)) return false; if(!pRefHoleRight.Resize(Height, Width*SampleFactor, 400)) return false; xFileConvertingfor1DMode(&pRefLeft, &pRefRight, &pRefDepthLeft, &pRefDepthRight, &pRefHoleLeft, &pRefHoleRight); xBoundaryNoiseRemoval(&pRefLeft, &pRefRight, &pRefDepthLeft, &pRefDepthRight, &pRefHoleLeft, &pRefHoleRight, pSynYuvBuffer, true/*1D Mode*/); } return true; }
void TimeLineCells::mouseReleaseEvent( QMouseEvent* event ) { qDebug( "TimeLineCell: mouse release event." ); if ( event->button() != primaryButton ) return; primaryButton = Qt::NoButton; endY = startY; emit mouseMovedY( 0 ); timeLine->scrubbing = false; int frameNumber = getFrameNumber( event->pos().x() ); if ( frameNumber < 1 ) frameNumber = -1; int layerNumber = getLayerNumber( event->pos().y() ); if ( m_eType == TIMELINE_CELL_TYPE::Tracks && primaryButton != Qt::MidButton && layerNumber != -1 && layerNumber < mEditor->object()->getLayerCount() ) { Layer *currentLayer = mEditor->object()->getLayer(layerNumber); if (!timeLine->scrubbing && !movingFrames && !clickSelecting && !boxSelecting ) { // Deselecting if we didn't move, scrub nor select anything // if ( event->modifiers() == Qt::ControlModifier ) { // Add/remove from already selected currentLayer->toggleFrameSelected(frameNumber, true); } else { currentLayer->toggleFrameSelected(frameNumber, false); } } currentLayer->mouseRelease( event, frameNumber ); } if ( m_eType == TIMELINE_CELL_TYPE::Layers && layerNumber != startLayerNumber && startLayerNumber != -1 && layerNumber != -1 ) { mEditor->moveLayer( startLayerNumber, layerNumber ); } timeLine->updateContent(); }
void TimeLineCells::mousePressEvent( QMouseEvent* event ) { if ( primaryButton != Qt::NoButton ) return; int frameNumber = getFrameNumber( event->pos().x() ); int layerNumber = getLayerNumber( event->pos().y() ); startY = event->pos().y(); startLayerNumber = layerNumber; endY = event->pos().y(); startFrameNumber = frameNumber; lastFrameNumber = startFrameNumber; canMoveFrame = false; movingFrames = false; canBoxSelect = false; boxSelecting = false; clickSelecting = false; primaryButton = event->button(); mEditor->tools()->currentTool()->switchingLayers(); switch ( m_eType ) { case TIMELINE_CELL_TYPE::Layers: if ( layerNumber != -1 && layerNumber < mEditor->object()->getLayerCount() ) { if ( event->pos().x() < 15 ) { mEditor->switchVisibilityOfLayer( layerNumber ); } else { mEditor->layers()->setCurrentLayer( layerNumber ); } } if ( layerNumber == -1 ) { if ( event->pos().x() < 15 ) { mEditor->toggleShowAllLayers(); } } break; case TIMELINE_CELL_TYPE::Tracks: if ( event->button() == Qt::MidButton ) { lastFrameNumber = getFrameNumber( event->pos().x() ); } else { if ( frameNumber == mEditor->currentFrame() && ( !shortScrub || ( shortScrub && startY < 20 ) ) ) { if (mEditor->playback()->isPlaying()) { mEditor->playback()->stop(); } timeLine->scrubbing = true; } else { if ( ( layerNumber != -1 ) && layerNumber < mEditor->object()->getLayerCount() ) { int previousLayerNumber = mEditor->layers()->currentLayerIndex(); if (previousLayerNumber != layerNumber) { Layer *previousLayer = mEditor->object()->getLayer(previousLayerNumber); previousLayer->deselectAll(); mEditor->setCurrentLayer( layerNumber ); } Layer *currentLayer = mEditor->object()->getLayer(layerNumber); // Check if we are using the alt key // if (event->modifiers() == Qt::AltModifier) { // If it is the case, we select everything that is after the selected frame // clickSelecting = true; canMoveFrame = true; currentLayer->selectAllFramesAfter(frameNumber); } // Check if we are clicking on a non selected frame // else if (!currentLayer->isFrameSelected(frameNumber)) { // If it is the case, we select it // canBoxSelect = true; clickSelecting = true; if ( event->modifiers() == Qt::ControlModifier ) { // Add/remove from already selected currentLayer->toggleFrameSelected(frameNumber, true); } else if ( event->modifiers() == Qt::ShiftModifier ) { // Select a range from the last selected currentLayer->extendSelectionTo(frameNumber); } else { currentLayer->toggleFrameSelected(frameNumber, false); } } else { // We clicked on a selected frame, we can move it // canMoveFrame = true; } currentLayer->mousePress( event, frameNumber ); timeLine->updateContent(); } else { if ( frameNumber > 0 ) { if (mEditor->playback()->isPlaying()) { mEditor->playback()->stop(); } mEditor->scrubTo( frameNumber ); timeLine->scrubbing = true; qDebug( "Scrub to %d frame", frameNumber ); } } } } break; } }
void BAnimation::Update ( float dt ) { time += dt; frameNumber = getFrameNumber() % frames.size() ; }
//run the OPT algorithm simulation void simulateOpt(bit32 numFrames, const char *fileName) { struct memRef *memList, *curr; //list of memory references bit32 *pageTable; //page table struct nextUse **future; //array of nextUse structures struct nextUse *tempFuture; //used to deallocate nodes of future use bit32 numFaults = 0, numWrites = 0, numRefs = 0; //stat counters struct optFrame *frames; //frame structure bit32 i, pageNo, frameNo, usedFrames = 0; //loop control, page number, frame number, and number of used frames //set up page table and ensure all bits are 0 pageTable = (bit32 *) malloc(NUM_PAGES * sizeof(bit32)); memset(pageTable, 0, sizeof(bit32) * NUM_PAGES); //set up the future array future = (struct nextUse **) malloc(sizeof(struct nextUse *) * NUM_PAGES); for(i = 0; i < NUM_PAGES; i++) { struct nextUse *temp = (struct nextUse *) malloc(sizeof(struct nextUse)); temp->time = MAX_UINT; temp->next = NULL; temp->tail = NULL; *(future + i) = temp; } //read the file in and store the references and future uses of the references readOptFile(&memList, future, fileName); //set up memory frames frames = (struct optFrame *) malloc(sizeof(struct optFrame) * numFrames); for(i = 0; i < numFrames; i++) { frames[i].pageNo = MAX_UINT; frames[i].next = *(future + i); } curr = memList; while(curr != NULL) { pageNo = getPageNumber(curr->reference); if(isValid(pageTable, pageNo)) { //page already already valid/in a frame - hit pageHitSetBits(pageTable, pageNo, curr->mode); //set appropriate bits frameNo = getFrameNumber(pageTable, pageNo); //get the frame number for this page tempFuture = future[pageNo]; //store current use for deallocation future[pageNo] = future[pageNo]->next; //move the next use down one frames[frameNo].next = future[pageNo]; //update the future array with next use of this page free(tempFuture); //deallocate printf("%i\thit\n", numRefs + 1); } else { //page is not in a frame yet - miss numFaults++; //compulsory miss - will only happen numFrames times if(usedFrames < numFrames) { frames[usedFrames].pageNo = pageNo; //store the page number in the frame tempFuture = future[pageNo]; //store current use for deallocation future[pageNo] = future[pageNo]->next; //move the next use of this page down frames[usedFrames].next = future[pageNo]; //update the link to future use in the frame table free(tempFuture); //deallocate the current use placePageInFrame(pageTable, pageNo, usedFrames, curr->mode); //map current page to frame usedFrames++; printf("%i\tpage fault - no eviction\n", numRefs + 1); } else { //capacity miss - evict page not used until furthest in future bit32 furthest = 0; //index of the page with the furthest future use bit32 ptIndex; //page number of the page used furthest in the future i = 0; if(frames[i].next == NULL) { //there is not future use of this page - we were lucky, can avoid loop furthest = i; } else { for(i = 1; i < numFrames; i++) { if(frames[i].next == NULL) { //there is no future use of this page - can safely remove furthest = i; //printf("\tNULL FOUND: furthest = %i", furthest); i = numFrames; //exit loop } else { //find the furthest future use of a page if(frames[i].next->time > frames[furthest].next->time) { furthest = i; } } } } //evict page in frame[furthest] - page used furthest in future ptIndex = frames[furthest].pageNo; if(isDirty(pageTable, ptIndex)) { numWrites++; printf("%i\tpage fault - evict dirty\n", numRefs + 1); } else { printf("%i\tpage fault - evict clean\n", numRefs + 1); } evictPage(pageTable, ptIndex); frames[furthest].pageNo = pageNo; //store the page number in the frame tempFuture = future[pageNo]; //store current use for deallocation future[pageNo] = future[pageNo]->next; //move future use down to next use frames[furthest].next = future[pageNo]; //update the frames reference to the future table free(tempFuture); //deallocate memory placePageInFrame(pageTable, pageNo, furthest, curr->mode); //map current page to frame } } //increment number of references and move to next reference numRefs++; curr = curr->next; } //print stats printf("\nNRU\n"); printf("Number of frames:\t%i\n", numFrames); printf("Total memory accesses:\t%i\n", numRefs); printf("Total page faults:\t%i\n", numFaults); printf("Total writes to disk:\t%i\n\n", numWrites); //clean up memory free(frames); free(future); }