void MpcImportWindow::resetDialog() { ui->stackedWidget->setCurrentIndex(0); //ui->tabWidget->setCurrentIndex(0); ui->groupBoxType->setVisible(true); ui->radioButtonAsteroids->setChecked(true); ui->radioButtonURL->setChecked(true); ui->frameFile->setVisible(false); ui->lineEditFilePath->clear(); ui->lineEditQuery->clear(); ui->lineEditURL->setText("http://"); ui->checkBoxAddBookmark->setChecked(false); ui->frameBookmarkTitle->setVisible(false); ui->comboBoxBookmarks->setCurrentIndex(0); ui->radioButtonUpdate->setChecked(true); ui->checkBoxOnlyOrbitalElements->setChecked(true); //TODO: Is this the right place? ui->pushButtonAbortQuery->setVisible(false); ui->pushButtonAbortDownload->setVisible(false); //Resetting the dialog should not reset the timer //resetCountdown(); resetNotFound(); enableInterface(true); }
void SignalGenerator::stopRunning() { // Stop the audio and video output streams immediately deckLinkOutput->StopScheduledPlayback(0, NULL, 0); // deckLinkOutput->DisableAudioOutput(); deckLinkOutput->DisableVideoOutput(); if (videoFrameBlack != NULL) videoFrameBlack->Release(); videoFrameBlack = NULL; if (videoFrameBars != NULL) videoFrameBars->Release(); videoFrameBars = NULL; if (audioBuffer != NULL) free(audioBuffer); audioBuffer = NULL; // Success; update the UI running = false; ui->startButton->setText("Start"); enableInterface(true); }
SignalGenerator::SignalGenerator() :QDialog() { running = false; deckLink = NULL; deckLinkOutput = NULL; videoFrameBlack = NULL; videoFrameBars = NULL; audioBuffer = NULL; timeCode = NULL; ui = new Ui::SignalGeneratorDialog(); ui->setupUi(this); layout = new QGridLayout(ui->previewContainer); layout->setMargin(0); previewView = new CDeckLinkGLWidget(this); previewView->resize(ui->previewContainer->size()); previewView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layout->addWidget(previewView, 0, 0, 0, 0); previewView->DrawFrame(NULL); ui->outputSignalPopup->addItem("Pip", QVariant::fromValue((int)kOutputSignalPip)); ui->outputSignalPopup->addItem("Dropout", QVariant::fromValue((int)kOutputSignalDrop)); ui->audioChannelPopup->addItem("2", QVariant::fromValue(2)); ui->audioChannelPopup->addItem("8", QVariant::fromValue(8)); ui->audioChannelPopup->addItem("16", QVariant::fromValue(16)); ui->audioSampleDepthPopup->addItem("16", QVariant::fromValue(16)); ui->audioSampleDepthPopup->addItem("32", QVariant::fromValue(32)); connect(ui->startButton, SIGNAL(clicked()), this, SLOT(toggleStart())); enableInterface(false); show(); }
void Mci::initialise(mci::CardSlot_t cardSlot) { OSDeviceDebug::putString("avr32::uc3::Mci::initialise()"); OSDeviceDebug::putNewLine(); m_shadowStatusRegister = 0; softwareReset(); disableInterface(); disableAllInterrupts(); clearConfiguration(); clearModeBits(); // Set the Data Timeout Register to 1 Mega Cycles initDataTimeout(MCI_DEFAULT_DTOLMUL, MCI_DEFAULT_DTOLCYC); // Start with low speed configureClockFrequencyHz(400000); // Set the Mode register // The two bits, Read Proof Enable and Write Proof Enable in the // MR register (MR.RDPROOF and MR.WRPROOF) allow stopping the // MCI Clock (CLK) during read or write access if the internal // FIFO is full. This will guarantee data integrity, not bandwidth enableModeBits( (MCI_DEFAULT_PWSDIV << AVR32_MCI_MR_PWSDIV) | AVR32_MCI_MR_RDPROOF_MASK | AVR32_MCI_MR_WRPROOF_MASK); // Set the SD/MMC Card register // Start with bus width = 1bit configureSdCardBusWidthAndSlot(mci::BusWidth::_1bit, cardSlot); // Enable the MCI and the Power Saving // The Power Save Mode Enable bit in the CR register (CR.PWSEN) // saves power by dividing the MCI clock (CLK) by 2PWSDIV + 1 // when the bus is inactive. The Power Saving Divider field locates // in the Mode Register (MR.PWSDIV). enableInterface(); }
SWCreateAvatarInterface::SWCreateAvatarInterface(QApplication *parent) : m_uiCreateAvatar(new Ui::SWUI_WCreateAvatar), m_oTimer(new QBasicTimer), m_bGLFullScreen(false) { // set absolute path m_absolutePath = QDir::currentPath() + "/"; m_bWorkStarted = false; m_bResetKinect = false; // init rects m_oFaceRect.width = 0; m_oNoseRect.width = 0; // init main widget m_uiCreateAvatar->setupUi(this); this->setWindowTitle(QString("SWoOz : Create avatar")); this->setWindowIcon(QIcon(m_absolutePath + "../data/images/logos/icon_swooz_avatar.png")); // init opengl context QHBoxLayout *l_pGLContainerLayout = new QHBoxLayout(); l_pGLContainerLayout->layout()->setContentsMargins(0,0,0,0); m_pGLContainer = new QWidget(); QGLFormat l_glFormat; l_glFormat.setVersion( 4, 3 ); l_glFormat.setProfile(QGLFormat::CompatibilityProfile); l_glFormat.setSampleBuffers(true); QGLContext *l_glContext1 = new QGLContext(l_glFormat); QGLContext *l_glContext2 = new QGLContext(l_glFormat); // add widgets // display widgets // rgb m_WRGBDisplay = new SWDisplayImageWidget(this); m_uiCreateAvatar->hlRGB->addWidget(m_WRGBDisplay); // radial proj m_WRadialProjDisplay = new SWDisplayImageWidget(this, false, true); m_uiCreateAvatar->hlRadial->addWidget(m_WRadialProjDisplay); // face texture m_WFaceTextureDisplay = new SWDisplayImageWidget(this); m_uiCreateAvatar->hlFaceTexture->addWidget(m_WFaceTextureDisplay); // cloud gl widget m_WCloudGL = new SWGLCloudWidget(l_glContext1, this); m_WCloudGL->setCameraMode(SWQtCamera::TRACKBALL_CAMERA); // m_WCloudGL->setMaximumSize(640,480); m_uiCreateAvatar->hlCloud->addWidget(m_WCloudGL); // mesh gl widget m_WMeshGL = new SWGLMeshWidget(l_glContext2, this, m_absolutePath + "../data/shaders/createAvatarMesh.vert", m_absolutePath + "../data/shaders/createAvatarMesh.frag"); m_WMeshGL->setCameraMode(SWQtCamera::TRACKBALL_CAMERA); m_pGLContainer->setLayout(l_pGLContainerLayout); l_pGLContainerLayout->addWidget(m_WMeshGL); m_uiCreateAvatar->hlMesh->addWidget(m_pGLContainer); // init workers m_WCreateAvatar = new SWCreateAvatarWorker(&m_oKinectThread); // set connections // menu QObject::connect(m_uiCreateAvatar->actionExit, SIGNAL(triggered()), parent, SLOT(quit())); QObject::connect(m_uiCreateAvatar->actionOnline_documentation, SIGNAL(triggered()), this, SLOT(openOnlineDocumentation())); QObject::connect(m_uiCreateAvatar->actionSave_result, SIGNAL(triggered()), this, SLOT(saveMeshFile())); QObject::connect(m_uiCreateAvatar->actionAbout, SIGNAL(triggered()), this, SLOT(openAboutWindow())); // start work QObject::connect(m_uiCreateAvatar->pbStart, SIGNAL(clicked()), this, SLOT(startWork())); QObject::connect(this, SIGNAL(startWorkSignal()), m_WCreateAvatar, SLOT(doWork())); // stop work QObject::connect(m_uiCreateAvatar->pbStop, SIGNAL(clicked()), m_WCreateAvatar, SLOT(stopWork())); QObject::connect(this, SIGNAL(leaveProgram()), m_WCreateAvatar, SLOT(stopWork())); QObject::connect(m_WCreateAvatar, SIGNAL(stopWorkSignal()), SLOT(switchDetect())); // reconstruct QObject::connect(m_uiCreateAvatar->pbReconstruct, SIGNAL(clicked()), m_WCreateAvatar, SLOT(reconstruct())); // reset selected contours QObject::connect(m_uiCreateAvatar->pbResetSelectedContours, SIGNAL(clicked()), m_WCreateAvatar, SLOT(resetDeletedPointsRadialProj())); QObject::connect(m_uiCreateAvatar->pbResetSelectedContours, SIGNAL(clicked()), m_WRadialProjDisplay, SLOT(resetSelectedPoints())); // rectangles QObject::connect(m_WCreateAvatar, SIGNAL(sendFaceRect(cv::Rect*)), this, SLOT(updateFaceRectangle(cv::Rect*))); QObject::connect(m_WCreateAvatar, SIGNAL(sendNoseRect(cv::Rect*)), this, SLOT(updateNoseRectangle(cv::Rect*))); // stasmm points QObject::connect(m_WCreateAvatar, SIGNAL(sendStasmPoints(std::vector<cv::Point2i>)), this, SLOT(updateStasmPoints(std::vector<cv::Point2i>))); // cloud QObject::connect(m_WCreateAvatar, SIGNAL(sendCloud(swCloud::SWCloud*, bool)), m_WCloudGL, SLOT(setCloud(swCloud::SWCloud*, bool))); // mesh QObject::connect(m_WCreateAvatar, SIGNAL(sendMesh(swMesh::SWMesh*,bool)), m_WMeshGL, SLOT(setMesh(swMesh::SWMesh*,bool))); QObject::connect(m_uiCreateAvatar->pbSaveAvatar, SIGNAL(clicked()), this, SLOT(saveMeshFile())); QObject::connect(this, SIGNAL(saveMeshFileSignal(QString)), m_WCreateAvatar, SLOT(saveMeshFile(QString))); // ui QObject::connect(m_WCreateAvatar, SIGNAL(switchTab(int)),m_uiCreateAvatar->tw3D, SLOT(setCurrentIndex(int))); QObject::connect(m_WCreateAvatar, SIGNAL(enableInterfaceSignal()), this, SLOT(enableInterface())); // display QObject::connect(m_WCreateAvatar, SIGNAL(sendMat(cv::Mat*)), this, SLOT(updateRadialProjDisplay(cv::Mat*))); QObject::connect(m_WCreateAvatar, SIGNAL(sendTexture(cv::Mat*)), this, SLOT(udpdateTexture3DDisplay(cv::Mat*))); QObject::connect(m_WCreateAvatar, SIGNAL(sendTexture(cv::Mat*)), this, SLOT(updateFaceTextureDisplay(cv::Mat*))); // parameters // projection QObject::connect(m_uiCreateAvatar->sbWidth, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setRadialWidth(const int))); QObject::connect(m_uiCreateAvatar->sbHeight, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setRadialHeight(const int))); // QObject::connect(m_uiCreateAvatar->dsbRadius, SIGNAL(valueChanged(double)),m_WCreateAvatar, SLOT(setCylinderRadius(double))); QObject::connect(m_uiCreateAvatar->sbErode, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setErode(int))); QObject::connect(m_uiCreateAvatar->sbDilate, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setDilate(int))); QObject::connect(m_uiCreateAvatar->sbExpandValue,SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setExpandValue(int))); QObject::connect(m_uiCreateAvatar->sbExpandConnex,SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setExpandConnex(int))); QObject::connect(m_uiCreateAvatar->sbEraseValue,SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setEraseValue(int))); QObject::connect(m_uiCreateAvatar->sbEraseConnex,SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setEraseConnex(int))); // filter QObject::connect(m_uiCreateAvatar->sbColor, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setBilateralColor(const int))); QObject::connect(m_uiCreateAvatar->sbSpace, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setBilateralSpace(const int))); // QObject::connect(m_uiCreateAvatar->sbDiameter, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setBilateralDiameter(const int))); QObject::connect(m_uiCreateAvatar->sbClouds, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setCloudNumberValue(const int))); QObject::connect(m_uiCreateAvatar->cbBilateralFilter,SIGNAL(toggled(bool)) ,m_WCreateAvatar, SLOT(setUseBilateralFilter(bool))); // rgbd device QObject::connect(m_uiCreateAvatar->sbXOffset, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setCalibrationXValue(const int))); QObject::connect(m_uiCreateAvatar->sbYOffset, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setCalibrationYValue(const int))); QObject::connect(m_uiCreateAvatar->dsbFaceDepth,SIGNAL(valueChanged(double)), m_WCloudGL, SLOT(setDepthRect(const double))); QObject::connect(m_uiCreateAvatar->dsbFaceDepth,SIGNAL(valueChanged(double)), m_WCreateAvatar, SLOT(setDepthCloud(const double))); // misc QObject::connect(m_uiCreateAvatar->cbSTASM, SIGNAL(toggled(bool)) ,m_WCreateAvatar, SLOT(setUseStasm(bool))); // display QObject::connect(m_uiCreateAvatar->cbDisplayLines, SIGNAL(toggled(bool)), m_WMeshGL, SLOT(setMeshLinesRender(const bool))); QObject::connect(m_uiCreateAvatar->cbApplyTexture, SIGNAL(toggled(bool)), m_WMeshGL, SLOT(applyTexture(bool))); // QObject::connect(m_uiCreateAvatar->dsbFOV, SIGNAL(valueChanged(double)),m_WMeshGL, SLOT(setFOV(const double))); // QObject::connect(m_uiCreateAvatar->dsbFOV, SIGNAL(valueChanged(double)),m_WCloudGL, SLOT(setFOV(const double))); QObject::connect(m_WCreateAvatar, SIGNAL(sendNumCloud(int)), this, SLOT(setNumCloud(const int))); // reset kinect QObject::connect(m_uiCreateAvatar->sbDeviceMode,SIGNAL(valueChanged(int)), this, SLOT(resetKinect(int))); QObject::connect(m_WCreateAvatar, SIGNAL(endResetKinect()), this, SLOT(releaseKinectMutex())); // others QObject::connect(m_WRadialProjDisplay, SIGNAL(clickPoint(QPoint, QSize, bool)), m_WCreateAvatar, SLOT(addPointToDeleteRadialProj(QPoint, QSize, bool))); // fullscreen QObject::connect(m_WMeshGL, SIGNAL(enableFullScreen()), this, SLOT(enableGLFullScreen())); QObject::connect(m_WMeshGL, SIGNAL(disableFullScreen()), this, SLOT(disableGLFullScreen())); // init worker parameters values // radial projection width / height m_WCreateAvatar->setRadialWidth(m_uiCreateAvatar->sbWidth->value()); m_WCreateAvatar->setRadialHeight(m_uiCreateAvatar->sbHeight->value()); // spatial filter m_WCreateAvatar->setBilateralColor(m_uiCreateAvatar->sbColor->value()); m_WCreateAvatar->setBilateralSpace(m_uiCreateAvatar->sbSpace->value()); m_WCreateAvatar->setBilateralDiameter(-1); // temporal filter m_WCreateAvatar->setCloudNumberValue(m_uiCreateAvatar->sbClouds->value()); // calibration m_WCreateAvatar->setCalibrationXValue(m_uiCreateAvatar->sbXOffset->value()); m_WCreateAvatar->setCalibrationYValue(m_uiCreateAvatar->sbYOffset->value()); // expand / erase m_WCreateAvatar->setExpandValue(m_uiCreateAvatar->sbExpandValue->value()); m_WCreateAvatar->setExpandConnex(m_uiCreateAvatar->sbExpandConnex->value()); m_WCreateAvatar->setEraseValue(m_uiCreateAvatar->sbEraseValue->value()); m_WCreateAvatar->setEraseConnex(m_uiCreateAvatar->sbEraseConnex->value()); // dilate / erode m_WCreateAvatar->setDilate(m_uiCreateAvatar->sbDilate->value()); m_WCreateAvatar->setErode(m_uiCreateAvatar->sbErode->value()); // stasm m_WCreateAvatar->setUseStasm(m_uiCreateAvatar->cbSTASM->isChecked()); // cloud m_WCloudGL->setDepthRect(m_uiCreateAvatar->dsbFaceDepth->value()); m_WCreateAvatar->setDepthCloud(m_uiCreateAvatar->dsbFaceDepth->value()); // desactive debug interface components // m_uiCreateAvatar->laPixelDiameter->setVisible(false); // m_uiCreateAvatar->sbDiameter->setVisible(false); // m_uiCreateAvatar->laCynlinderRadius->setVisible(false); // m_uiCreateAvatar->dsbRadius->setVisible(false); // m_uiCreateAvatar->laFOV->setVisible(false); // m_uiCreateAvatar->dsbFOV->setVisible(false); setStyleSheet("QGroupBox { padding: 10 0px 0 0px; color: blue; border: 1px solid gray; border-radius: 5px; margin-top: 1ex; /* leave space at the top for the title */}"); // init and start create avatar thread m_WCreateAvatar->moveToThread(&m_TCreateAvatar); m_TCreateAvatar.start(); // init face detection m_CFaceDetectPtr = SWFaceDetectionPtr(new swDetect::SWFaceDetection(cv::Size(80,80))); m_oLastRectFace.width = 0; // launch timer for updating the display widget m_oTimer->start(1000/30, this); }
void SignalGenerator::startRunning() { IDeckLinkDisplayMode* videoDisplayMode = NULL; BMDVideoOutputFlags videoOutputFlags = 0; QVariant v; // Determine the audio and video properties for the output stream v = ui->outputSignalPopup->itemData(ui->outputSignalPopup->currentIndex()); outputSignal = (OutputSignal)v.value<int>(); v = ui->audioChannelPopup->itemData(ui->audioChannelPopup->currentIndex()); audioChannelCount = v.value<int>(); v = ui->audioSampleDepthPopup->itemData(ui->audioSampleDepthPopup->currentIndex()); audioSampleDepth = v.value<int>(); audioSampleRate = bmdAudioSampleRate48kHz; // // - Extract the IDeckLinkDisplayMode from the display mode popup menu (stashed in the item's tag) v = ui->videoFormatPopup->itemData(ui->videoFormatPopup->currentIndex()); videoDisplayMode = (IDeckLinkDisplayMode *)v.value<void*>(); frameWidth = videoDisplayMode->GetWidth(); frameHeight = videoDisplayMode->GetHeight(); videoDisplayMode->GetFrameRate(&frameDuration, &frameTimescale); // Calculate the number of frames per second, rounded up to the nearest integer. For example, for NTSC (29.97 FPS), framesPerSecond == 30. framesPerSecond = (frameTimescale + (frameDuration-1)) / frameDuration; if (videoDisplayMode->GetDisplayMode() == bmdModeNTSC || videoDisplayMode->GetDisplayMode() == bmdModeNTSC2398 || videoDisplayMode->GetDisplayMode() == bmdModePAL) { timeCodeFormat = bmdTimecodeVITC; videoOutputFlags |= bmdVideoOutputVITC; } else { timeCodeFormat = bmdTimecodeRP188Any; videoOutputFlags |= bmdVideoOutputRP188; } if (timeCode) delete timeCode; timeCode = new Timecode(framesPerSecond); // Set the video output mode if (deckLinkOutput->EnableVideoOutput(videoDisplayMode->GetDisplayMode(), videoOutputFlags) != S_OK) goto bail; // Set the audio output mode if (deckLinkOutput->EnableAudioOutput(bmdAudioSampleRate48kHz, audioSampleDepth, audioChannelCount, bmdAudioOutputStreamTimestamped) != S_OK) goto bail; // Generate one second of audio tone audioSamplesPerFrame = ((audioSampleRate * frameDuration) / frameTimescale); audioBufferSampleLength = (framesPerSecond * audioSampleRate * frameDuration) / frameTimescale; audioBuffer = malloc(audioBufferSampleLength * audioChannelCount * (audioSampleDepth / 8)); if (audioBuffer == NULL) goto bail; FillSine(audioBuffer, audioBufferSampleLength, audioChannelCount, audioSampleDepth); // Generate a frame of black if (deckLinkOutput->CreateVideoFrame(frameWidth, frameHeight, frameWidth*2, bmdFormat8BitYUV, bmdFrameFlagDefault, &videoFrameBlack) != S_OK) goto bail; FillBlack(videoFrameBlack); // Generate a frame of colour bars if (deckLinkOutput->CreateVideoFrame(frameWidth, frameHeight, frameWidth*2, bmdFormat8BitYUV, bmdFrameFlagDefault, &videoFrameBars) != S_OK) goto bail; FillColourBars(videoFrameBars); // Begin video preroll by scheduling a second of frames in hardware totalFramesScheduled = 0; for (unsigned int i = 0; i < framesPerSecond; i++) scheduleNextFrame(true); // Begin audio preroll. This will begin calling our audio callback, which will start the DeckLink output stream. totalAudioSecondsScheduled = 0; if (deckLinkOutput->BeginAudioPreroll() != S_OK) goto bail; // Success; update the UI running = true; ui->startButton->setText("Stop"); // Disable the user interface while running (prevent the user from making changes to the output signal) enableInterface(false); return; bail: QMessageBox::critical(this, "Failed to start output", "Failed to start output"); // *** Error-handling code. Cleanup any resources that were allocated. *** // stopRunning(); }
void SignalGenerator::setup() { IDeckLinkIterator* deckLinkIterator = NULL; bool success = false; // **** Find a DeckLink instance and obtain video output interface deckLinkIterator = CreateDeckLinkIteratorInstance(); if (deckLinkIterator == NULL) { QMessageBox::critical(this, "This application requires the DeckLink drivers installed.", "Please install the Blackmagic DeckLink drivers to use the features of this application."); goto bail; } // Connect to the first DeckLink instance if (deckLinkIterator->Next(&deckLink) != S_OK) { QMessageBox::critical(this, "This application requires a DeckLink PCI card.", "You will not be able to use the features of this application until a DeckLink PCI card is installed."); goto bail; } // Obtain the audio/video output interface (IDeckLinkOutput) if (deckLink->QueryInterface(IID_IDeckLinkOutput, (void**)&deckLinkOutput) != S_OK) goto bail; // Create a delegate class to allow the DeckLink API to call into our code playerDelegate = new PlaybackDelegate(this, deckLinkOutput); if (playerDelegate == NULL) goto bail; // Provide the delegate to the audio and video output interfaces deckLinkOutput->SetScheduledFrameCompletionCallback(playerDelegate); deckLinkOutput->SetAudioCallback(playerDelegate); // Populate the display mode menu with a list of display modes supported by the installed DeckLink card IDeckLinkDisplayModeIterator* displayModeIterator; IDeckLinkDisplayMode* deckLinkDisplayMode; ui->videoFormatPopup->clear(); if (deckLinkOutput->GetDisplayModeIterator(&displayModeIterator) != S_OK) goto bail; while (displayModeIterator->Next(&deckLinkDisplayMode) == S_OK) { const char * modeName; if (deckLinkDisplayMode->GetName(&modeName) == S_OK) { ui->videoFormatPopup->addItem(modeName, QVariant::fromValue((void *)deckLinkDisplayMode)); } } displayModeIterator->Release(); enableInterface(true); deckLinkOutput->SetScreenPreviewCallback(previewView); success = true; bail: if (success == false) { // Release any resources that were partially allocated if (deckLinkOutput != NULL) { deckLinkOutput->Release(); deckLinkOutput = NULL; } // if (deckLink != NULL) { deckLink->Release(); deckLink = NULL; } // Disable the user interface if we could not succsssfully connect to a DeckLink device ui->startButton->setEnabled(false); enableInterface(false); } if (deckLinkIterator != NULL) deckLinkIterator->Release(); }