void handleUserInput(FrameDisplayer& frameDisplayer, std::vector<std::shared_ptr<PoseExtractorNet>>& poseExtractorNets, std::vector<std::shared_ptr<FaceExtractorNet>>& faceExtractorNets, std::vector<std::shared_ptr<HandExtractorNet>>& handExtractorNets, std::vector<std::shared_ptr<Renderer>>& renderers, std::shared_ptr<std::atomic<bool>>& isRunningSharedPtr, std::shared_ptr<std::pair<std::atomic<bool>, std::atomic<int>>>& videoSeekSharedPtr, DisplayMode& displayMode, DisplayMode& displayModeOriginal) { try { // The handleUserInput must be always performed, even if no tDatum is detected bool guiPaused = false; handleWaitKey(guiPaused, frameDisplayer, poseExtractorNets, faceExtractorNets, handExtractorNets, renderers, isRunningSharedPtr, videoSeekSharedPtr, displayMode, displayModeOriginal); while (guiPaused) { std::this_thread::sleep_for(std::chrono::milliseconds{1}); handleWaitKey(guiPaused, frameDisplayer, poseExtractorNets, faceExtractorNets, handExtractorNets, renderers, isRunningSharedPtr, videoSeekSharedPtr, displayMode, displayModeOriginal); } } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); } }
bool Script::executeCommand(int index, MasterTimer* timer, QList<Universe *> universes) { if (index < 0 || index >= m_lines.size()) { qWarning() << "Invalid command index:" << index; return false; } QList <QStringList> tokens = m_lines[index]; if (tokens.isEmpty() == true) return true; // Empty line bool continueLoop = true; QString error; if (tokens[0].size() < 2) { error = QString("Syntax error"); } else if (tokens[0][0] == Script::startFunctionCmd) { error = handleStartFunction(tokens, timer); } else if (tokens[0][0] == Script::stopFunctionCmd) { error = handleStopFunction(tokens); } else if (tokens[0][0] == Script::waitCmd) { // Waiting should break out of the execution loop to prevent skipping // straight to the next command. If there is no error in wait parsing, // we must wait at least one cycle. error = handleWait(tokens); if (error.isEmpty() == true) continueLoop = false; } else if (tokens[0][0] == Script::waitKeyCmd) { // Waiting for a key should break out of the execution loop to prevent // skipping straight to the next command. If there is no error in waitkey // parsing,we must wait at least one cycle. error = handleWaitKey(tokens); if (error.isEmpty() == true) continueLoop = false; } else if (tokens[0][0] == Script::setFixtureCmd) { error = handleSetFixture(tokens, universes); } else if (tokens[0][0] == Script::labelCmd) { error = handleLabel(tokens); } else if (tokens[0][0] == Script::jumpCmd) { // Jumping can cause an infinite non-waiting loop, causing starvation // among other functions. Therefore, the script must relinquish its // time slot after each jump. If there is no error in jumping, the jump // must have happened. error = handleJump(tokens); if (error.isEmpty() == true) continueLoop = false; } else { error = QString("Unknown command: %1").arg(tokens[0][0]); } if (error.isEmpty() == false) qWarning() << QString("Script:%1, line:%2, error:%3").arg(name()).arg(index).arg(error); return continueLoop; }