Ejemplo n.º 1
0
void InputManager::inputChangedHandler()
{
    setInput( THEMIM->getInput() );
}
Ejemplo n.º 2
0
TEST_F(Solver580DTest, Example4)
{
    setInput("2 1 0        15 14");
    Solver580D().run();
    EXPECT_EQ("15", getOutput());
}
//------------------------------------------------------------------------------
bool ofRtAudioSoundStream::setup(ofBaseApp * app, int outChannels, int inChannels, int sampleRate, int bufferSize, int nBuffers){
	setInput(app);
	setOutput(app);
	return setup(outChannels,inChannels,sampleRate,bufferSize,nBuffers);
}
Ejemplo n.º 4
0
/** 
 * motionMagnify	-	eulerian motion magnification
 *
 */
void VideoProcessor::motionMagnify()
{
    // set filter
    setSpatialFilter(LAPLACIAN);
    setTemporalFilter(IIR);

    // create a temp file
    createTemp();

    // current frame
    cv::Mat input;
    // output frame
    cv::Mat output;

    // motion image
    cv::Mat motion;

    std::vector<cv::Mat> pyramid;
    std::vector<cv::Mat> filtered;

    // if no capture device has been set
    if (!isOpened())
        return;

    // set the modify flag to be true
    modify = true;

    // is processing
    stop = false;

    // save the current position
    long pos = curPos;
    // jump to the first frame
    jumpTo(0);

    while (!isStop()) {

        // read next frame if any
        if (!getNextFrame(input))
            break;

        input.convertTo(input, CV_32FC3, 1.0/255.0f);

        // 1. convert to Lab color space
        cv::cvtColor(input, input, CV_BGR2Lab);

        // 2. spatial filtering one frame
        cv::Mat s = input.clone();
        spatialFilter(s, pyramid);

        // 3. temporal filtering one frame's pyramid
        // and amplify the motion
        if (fnumber == 0){      // is first frame
            lowpass1 = pyramid;
            lowpass2 = pyramid;
            filtered = pyramid;
        } else {
            for (int i=0; i<levels; ++i) {
                curLevel = i;
                temporalFilter(pyramid.at(i), filtered.at(i));
            }

            // amplify each spatial frequency bands
            // according to Figure 6 of paper            
            cv::Size filterSize = filtered.at(0).size();
            int w = filterSize.width;
            int h = filterSize.height;

            delta = lambda_c/8.0/(1.0+alpha);
            // the factor to boost alpha above the bound
            // (for better visualization)
            exaggeration_factor = 2.0;

            // compute the representative wavelength lambda
            // for the lowest spatial frequency band of Laplacian pyramid
            lambda = sqrt(w*w + h*h)/3;  // 3 is experimental constant

            for (int i=levels; i>=0; i--) {
                curLevel = i;

                amplify(filtered.at(i), filtered.at(i));

                // go one level down on pyramid
                // representative lambda will reduce by factor of 2
                lambda /= 2.0;
            }
        }

        // 4. reconstruct motion image from filtered pyramid
        reconImgFromLaplacianPyramid(filtered, levels, motion);

        // 5. attenuate I, Q channels
        attenuate(motion, motion);

        // 6. combine source frame and motion image
        if (fnumber > 0)    // don't amplify first frame
            s += motion;

        // 7. convert back to rgb color space and CV_8UC3
        output = s.clone();
        cv::cvtColor(output, output, CV_Lab2BGR);
        output.convertTo(output, CV_8UC3, 255.0, 1.0/255.0);

        // write the frame to the temp file
        tempWriter.write(output);

        // update process
        std::string msg= "Processing...";
        emit updateProcessProgress(msg, floor((fnumber++) * 100.0 / length));
    }
    if (!isStop()){
        emit revert();
    }
    emit closeProgressDialog();

    // release the temp writer
    tempWriter.release();

    // change the video to the processed video 
    setInput(tempFile);

    // jump back to the original position
    jumpTo(pos);
}
Ejemplo n.º 5
0
double runXOR(Network *network, unsigned long int maxRuns, bool trainNetwork) {

	ofstream outputFile;
	/*string fileName = "output" + to_string(threadIndex) + ".txt";*/
	string fileName = "output_xor.txt";
	outputFile.open(fileName, ios::out);

	vector<double> input;
	vector<double> expectedOutput;

	double meanError = 0.0;

	for (unsigned long int run = 1; run <= maxRuns; run++) {

		setInput(&input, run);

		network->feedInput(input);
		vector<double> output = network->getOutput();

		//FIXME: am un bias neuron in output (!)
		//if (output.size() != 1) {
		//	throw runtime_error("Invalid output received");
		//}

		expectedOutput.clear();
		expectedOutput.push_back(xor (input.front(), input.back()));
		network->normalizeInput(&expectedOutput);

		double error = 0.0;

		if (!trainNetwork || ((double)run / (double)maxRuns >= 0.9)) {

			error = network->calculateRMSError(output, expectedOutput);
			meanError += error;
		}

		if (trainNetwork) {

			if (run >= maxRuns - pow(10, 2) || run <= pow(10, 2)) {

				error = network->calculateRMSError(output, expectedOutput);

				vector<double> denormOutput = output;
				network->denormalizeOutput(&denormOutput);

				vector<double> denormExpectedOutput = expectedOutput;
				network->denormalizeOutput(&denormExpectedOutput);

				logTrainingToFile(run, input, denormOutput.front(), denormExpectedOutput.front(), error, &outputFile);
			}

			if (run % (maxRuns / 10) == 0) {

				cout << (double)run / (double)maxRuns * 100 << "%" << "\t";
			}

			network->backPropagation(output, expectedOutput);
		}
	}

	outputFile.close();

	if (trainNetwork) {
		meanError /= 0.1 * maxRuns;
	}
	else {
		meanError /= maxRuns;
	}

	return meanError;
}
Ejemplo n.º 6
0
void DS1307__init (void)
{
    uint8_t data[2];
    uint8_t transmitState = E_NOT_OK;
    uint8_t receiveState = E_NOT_OK;

    /* set clock register */
    data[0] = 0x00;

    Debug__setWhileState(WHILE_STATE_DS13071_BEFORE);
    while (transmitState != E_OK)
    {
        transmitState = TWI__masterTransmitData(data, 1, DS1307_ADDRESS);
    }
    Debug__setWhileState(WHILE_STATE_DS13071_AFTER);

    transmitState = E_NOT_OK;

    /* read first byte */
    Debug__setWhileState(WHILE_STATE_DS13072_BEFORE);
    while (receiveState != E_OK)
    {
        receiveState = TWI__masterReadData (&data[1], 1, DS1307_ADDRESS);
    }
    Debug__setWhileState(WHILE_STATE_DS13072_AFTER);

    receiveState = E_NOT_OK;

    /* enable oscillator */
    data[1] &= (~(1 << 7));

    Debug__setWhileState(WHILE_STATE_DS13073_BEFORE);
    while (transmitState != E_OK)
    {
        transmitState = TWI__masterTransmitData(data, 2, DS1307_ADDRESS);
    }
    Debug__setWhileState(WHILE_STATE_DS13073_AFTER);

    transmitState = E_NOT_OK;

    /* set control register and enable SQW output - 1 Hz */
    data[0] = 0x07;
    data[1] = (1 << 4);

    Debug__setWhileState(WHILE_STATE_DS13074_BEFORE);
    while (transmitState != E_OK)
    {
        transmitState = TWI__masterTransmitData(data, 2, DS1307_ADDRESS);
    }
    Debug__setWhileState(WHILE_STATE_DS13074_AFTER);

    transmitState = E_NOT_OK;

    DS1307__sendTimeToRTC();

#if (DS1307_MODE == DS1307_MODE_TWI_SQW)
    setInput(DS1307_SQW_DDR, DS1307_SQW_PIN);
    /* !! For TWI+SQW mode Pin PC7 has to be used !! */
    PCICR |= (1 << PCIE2);
    PCMSK2 |= (1 << PCINT23);
#endif

    triggerUpdateFromRTC = TRUE;
}
Ejemplo n.º 7
0
void InputManager::inputChangedHandler()
{
    setInput( p_mim->getInput() );
}
void UBKeyboardPalette::syncLocale(int nLocale)
{
    nCurrentLocale = nLocale;
    setInput(locales[nCurrentLocale]);
}
Ejemplo n.º 9
0
TEST_F(Solver578BTest, Example1)
{
    setInput("3 1 2    1 1 1");
    Solver578B().run();
    EXPECT_EQ("3", getOutput());
}
Ejemplo n.º 10
0
Archivo: gui.cpp Proyecto: jurkan/mana
Gui::Gui(Graphics *graphics):
    mCustomCursor(false),
    mMouseCursors(NULL),
    mMouseCursorAlpha(1.0f),
    mMouseInactivityTimer(0),
    mCursorType(CURSOR_POINTER)
{
    logger->log("Initializing GUI...");
    // Set graphics
    setGraphics(graphics);

    // Set input
    guiInput = new SDLInput;
    setInput(guiInput);

    // Set focus handler
    delete mFocusHandler;
    mFocusHandler = new FocusHandler;

    // Initialize top GUI widget
    WindowContainer *guiTop = new WindowContainer;
    guiTop->setFocusable(true);
    guiTop->setSize(graphics->getWidth(), graphics->getHeight());
    guiTop->setOpaque(false);
    Window::setWindowContainer(guiTop);
    setTop(guiTop);

    ResourceManager *resman = ResourceManager::getInstance();

    // Set global font
    const int fontSize = config.getValue("fontSize", 11);
    std::string fontFile = branding.getValue("font", "fonts/DejaVuSerifCondensed.ttf");
    std::string path = resman->getPath(fontFile);

    try
    {
        mGuiFont = new TrueTypeFont(path, fontSize);
        mInfoParticleFont = new TrueTypeFont(path, fontSize, TTF_STYLE_BOLD);
    }
    catch (gcn::Exception e)
    {
        logger->error(std::string("Unable to load '") + fontFile +
                      std::string("': ") + e.getMessage());
    }

    // Set bold font
    fontFile = branding.getValue("boldFont", "fonts/DejaVuSerifCondensed-Bold.ttf");
    path = resman->getPath(fontFile);
    try
    {
        boldFont = new TrueTypeFont(path, fontSize);
    }
    catch (gcn::Exception e)
    {
        logger->error(std::string("Unable to load '") + fontFile +
                      std::string("': ") + e.getMessage());
    }

    // Set mono font
    fontFile = branding.getValue("monoFont", "fonts/dejavusans-mono.ttf");
    path = resman->getPath(fontFile);
    try
    {
        monoFont = new TrueTypeFont(path, fontSize);
    }
    catch (gcn::Exception e)
    {
        logger->error(std::string("Unable to load '") + fontFile +
                      std::string("': ") + e.getMessage());
    }

    gcn::Widget::setGlobalFont(mGuiFont);

    // Initialize mouse cursor and listen for changes to the option
    setUseCustomCursor(config.getBoolValue("customcursor"));
    mConfigListener = new GuiConfigListener(this);
    mConfigListener->listen(Event::ConfigChannel);
}
Ejemplo n.º 11
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    _has_unsaved_data(true),
    _current_file(""),
    _can_run(false),
    _is_running(false),
    _is_debug_input(false)
{
    ui->setupUi(this);

    initStyles();
    updateWindowTitle();
    redoAvailable(false);
    undoAvailable(false);
    copyAvailable(false);



    _window = this;

    ui->debugRun->setVisible(false);
    ui->runWidget->setVisible(false);

    registerFileType(tr("Yad.Markov.File"),
                     tr("Markov Algorithm File"),
                     ".yad",
                     1);

    updateDebugMenu();

    //Connect MainWindow menu
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionUndo, SIGNAL(triggered()), this, SIGNAL(undo()));
    connect(ui->actionRedo, SIGNAL(triggered()), this, SIGNAL(redo()));
    connect(ui->actionSelect_All, SIGNAL(triggered()), this, SIGNAL(selectAll()));
    connect(ui->actionCopy, SIGNAL(triggered()), this, SIGNAL(copy()));
    connect(ui->actionPaste, SIGNAL(triggered()), this, SIGNAL(paste()));
    connect(ui->actionCut, SIGNAL(triggered()), this, SIGNAL(cut()));
    connect(ui->actionDelete, SIGNAL(triggered()), this, SIGNAL(deleteSelection()));
    connect(ui->actionNew, SIGNAL(triggered()), this, SIGNAL(newFile()));
    connect(ui->actionOpen, SIGNAL(triggered()), this, SIGNAL(open()));
    connect(ui->actionSave, SIGNAL(triggered()), this, SIGNAL(save()));
    connect(ui->actionSave_As, SIGNAL(triggered()), this, SIGNAL(saveAs()));
    connect(ui->actionTutorial, SIGNAL(triggered()), this, SLOT(tutorial()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));

    //Connect InputWidget and HistoryManager
    HistoryManager* history_manager = HistoryManager::getInstance();

    connect(ui->input, SIGNAL(addToHistory(QString)),
            history_manager, SLOT(addToHistory(QString)));
    connect(history_manager, SIGNAL(wordSelected(QString)),
            ui->input, SLOT(setInput(QString)));

    //Connect HistoryWidget and HistoryManager
    connect(ui->history, SIGNAL(inputWordSelected(QString)),
            history_manager, SIGNAL(wordSelected(QString)));
    connect(ui->history, SIGNAL(removeFromHistory(QString)),
            history_manager, SLOT(removeFromHistory(QString)));
    connect(history_manager, SIGNAL(historyChanged(QVector<QString>)),
            ui->history, SLOT(historyChanged(QVector<QString>)));

    //Connect MainWindows and FileManager
    FileManager* file_manager = FileManager::getInstance();
    connect(this, SIGNAL(newFile()), file_manager, SLOT(newFile()));
    connect(this, SIGNAL(open()), file_manager, SLOT(open()));
    connect(this, SIGNAL(save()), file_manager, SLOT(save()));
    connect(this, SIGNAL(saveAs()), file_manager, SLOT(saveAs()));
    connect(file_manager, SIGNAL(hasUnsavedData(bool)),
            this, SLOT(hasUnsavedData(bool)));
    connect(file_manager, SIGNAL(fileNameChanged(QString)),
            this, SLOT(fileNameChanged(QString)));

    //Connect MainWindows and EditorWindowWidget
    connect(this, SIGNAL(undo()), ui->editorWindow, SLOT(undo()));
    connect(this, SIGNAL(redo()), ui->editorWindow, SLOT(redo()));
    connect(this, SIGNAL(selectAll()), ui->editorWindow, SLOT(selectAll()));
    connect(this, SIGNAL(copy()), ui->editorWindow, SLOT(copy()));
    connect(this, SIGNAL(paste()), ui->editorWindow, SLOT(paste()));
    connect(this, SIGNAL(cut()), ui->editorWindow, SLOT(cut()));
    connect(this, SIGNAL(deleteSelection()),
            ui->editorWindow, SLOT(deleteSelection()));

    connect(ui->editorWindow, SIGNAL(redoAvailable(bool)),
            this, SLOT(redoAvailable(bool)));
    connect(ui->editorWindow, SIGNAL(undoAvailable(bool)),
            this, SLOT(undoAvailable(bool)));
    connect(ui->editorWindow, SIGNAL(copyAvailable(bool)),
            this, SLOT(copyAvailable(bool)));

    //Connect InputWidget and MarkovRunManager
    MarkovRunManager* run_manager = MarkovRunManager::getInstance();

    connect(ui->input, SIGNAL(run(QString)),
            run_manager, SLOT(runWithoutDebug(QString)));
    connect(ui->input, SIGNAL(runWithDebug(QString)),
            run_manager, SLOT(runWithDebug(QString)));
    connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)),
            ui->input, SLOT(runStarted()));
    connect(ui->input, SIGNAL(runWithDebugStepByStep(QString)),
            run_manager, SLOT(runWithDebugStepByStep(QString)));
    connect(run_manager, SIGNAL(debugStarted(QString)),
            ui->input, SLOT(runStarted()));
    connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)),
            ui->input, SLOT(runFinished()));
    connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)),
            ui->input, SLOT(runFinished()));
    connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)),
            ui->input, SLOT(runFinished()));
    connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)),
            ui->input, SLOT(runFinished()));
    connect(run_manager, SIGNAL(canRunSourceCode(bool)),
            ui->input, SLOT(canRunAlgorithm(bool)));

    //Connect SourceCodeManager and EditorWindowWidget
    SourceCodeManager* source_manager = SourceCodeManager::getInstance();
    connect(source_manager, SIGNAL(newSourceCodeWasLoaded(QString)),
            ui->editorWindow, SLOT(newSourceCode(QString)));
    connect(ui->editorWindow, SIGNAL(sourceCodeChanged(QString)),
            source_manager, SLOT(setSourceCode(QString)));

    //Connect InputWidget and FileManager
    connect(ui->input, SIGNAL(save()), file_manager, SLOT(save()));

    //Connect MarkovRunManager and EditorWindowWidget
    connect(ui->editorWindow, SIGNAL(canRun(bool)),
            run_manager, SLOT(setCanRunSourceCode(bool)));
    connect(ui->editorWindow, SIGNAL(markovAlgorithmChanged(MarkovAlgorithm)),
            run_manager, SLOT(setAlgorithm(MarkovAlgorithm)));

    //Connect SourceCodeManager and FileManager
    connect(file_manager, SIGNAL(newSourceCodeLoaded(QString)),
            source_manager, SLOT(setNewSourceCodeFromFile(QString)));
    connect(source_manager, SIGNAL(sourceCodeChanged(QString)),
            file_manager, SLOT(sourceCodeChanged()));

    //Connect FileManager and HistoryManager
    connect(file_manager, SIGNAL(newHistoryLoaded(QVector<QString>)),
            this, SLOT(newHistoryLoaded(QVector<QString>)));
    connect(history_manager, SIGNAL(historyChanged(QVector<QString>)),
            file_manager, SLOT(historyChanged()));

    //Connect RunWidget and MarkovRunManager
    connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)),
            ui->runWidget, SLOT(runStarted(QString)));
    connect(run_manager, SIGNAL(runStepsMade(int)),
            ui->runWidget, SLOT(runStepsMade(int)));
    connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)),
            ui->runWidget, SLOT(runFailed(QString,RunError,int)));
    connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)),
            ui->runWidget, SLOT(runSuccess(QString,QString,int)));
    connect(run_manager, SIGNAL(debugStarted(QString)),
            ui->runWidget, SLOT(hide()));

    //Connect DebugRunWidget and MarkovRunManager
    connect(ui->debugRun, SIGNAL(nextStepClicked()),
            run_manager, SLOT(debugNextStep()));
    connect(ui->debugRun, SIGNAL(continueClicked()),
            run_manager, SLOT(debugContinue()));
    connect(ui->debugRun, SIGNAL(stopClicked()),
            run_manager, SLOT(debugStop()));

    connect(run_manager, SIGNAL(debugStarted(QString)),
            ui->debugRun, SLOT(debugStarted(QString)));
    connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)),
            ui->debugRun, SLOT(debugSuccess(QString,QString,int)));
    connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)),
            ui->debugRun, SLOT(debugFailed(QString,RunError,int)));
    connect(run_manager, SIGNAL(debugStepFinished(int,QString,QString,MarkovRule)),
            ui->debugRun, SLOT(debugStepFinished(int,QString,QString,MarkovRule)));
    connect(run_manager, SIGNAL(debugBreakPointReached(int)),
            ui->debugRun, SLOT(breakPointReached(int)));
    connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)),
            ui->debugRun, SLOT(hide()));
    connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)),
            ui->runWidget, SLOT(hide()));
    connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)),
            ui->debugRun, SLOT(hide()));

    //Connect DebugRunWidget and EditorWindowWidget
    connect(ui->debugRun, SIGNAL(removeBreakPoint()),
            ui->editorWindow, SLOT(removeLineHighlight()));
    connect(ui->debugRun, SIGNAL(showBreakPoint(int)),
            ui->editorWindow, SLOT(showLineHighlight(int)));

    //Connect MarkovRunManager and EditorWindowWidget
    connect(ui->editorWindow, SIGNAL(breakPointAdded(int)),
            run_manager, SLOT(addBreakPoint(int)));
    connect(ui->editorWindow, SIGNAL(breakPointRemoved(int)),
            run_manager, SLOT(removeBreakPoint(int)));

    //Connect top menu
    connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)),
            this, SLOT(runStarted()));
    connect(run_manager, SIGNAL(debugStarted(QString)),
            this, SLOT(runStarted()));
    connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)),
            this, SLOT(runFinished()));
    connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)),
            this, SLOT(runFinished()));
    connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)),
            this, SLOT(runFinished()));
    connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)),
            this, SLOT(runFinished()));
    connect(run_manager, SIGNAL(canRunSourceCode(bool)),
            this, SLOT(canRunAlgorithm(bool)));
    connect(run_manager, SIGNAL(debugBreakPointReached(int)),
            this, SLOT(debugInputStarted()));
    connect(run_manager, SIGNAL(debugStepFinished(int,QString,QString,MarkovRule)),
            this, SLOT(debugInputFinished()));

    connect(ui->actionRun, SIGNAL(triggered()),
            ui->input, SLOT(runCliked()));
    connect(ui->actionDebug, SIGNAL(triggered()),
            ui->input, SLOT(runWithDebugClicked()));
    connect(ui->actionNext_Step, SIGNAL(triggered()),
            run_manager, SLOT(debugNextStep()));
    connect(ui->actionContinue, SIGNAL(triggered()),
            run_manager, SLOT(debugContinue()));
    connect(ui->actionStop_Debug, SIGNAL(triggered()),
            run_manager, SLOT(debugStop()));
    connect(ui->actionDebug_Step_By_Step, SIGNAL(triggered()),
            ui->input, SLOT(runWithDebugStepByStepClicked()));

    //Read file to open from command line
    QStringList arguments = QCoreApplication::arguments();
    if(arguments.size() >= 2)
    {
        QString file_name = arguments.at(1);
        FileManager::getInstance()->openFile(file_name);
    }
    else
    {
        source_manager->setNewSourceCodeFromFile(tr("//Alphabet\nT = {a, b}\n\n//Rules\nab -> a\na ->. b"));
    }

}
Ejemplo n.º 12
0
int main2(int argc, char **arg){
	char* error;
	int n = 3;

	/*start OpenGL*/
	initOpenGL();

	/*testing system compatibility*/
	if ((error = test()) != 0){
		printf("Error: %s\n", error);
		return -1;
	}

	/*initializing system.*/
	if (!init()){
		printf("Init not successful...");
		return -1;
	}

	/*create layers using the sigmoid_sum fragment program.*/
	A = generateLayer("sigmoid_sum_masked.fp", 4, 40, 0);
	B = generateLayer("sigmoid_sum_masked.fp", 40, 16, 0);
	C = generateLayer("sigmoid_sum_masked.fp", 40, 22, 16);
	D = generateLayer("sigmoid_sum_masked.fp", 38, 5, 0);
	E = generateLayer(0, 5, 0, 0);

	setOutput(A, B);
	setInput(C, A);
	setOutput(B, D);
	setOutput(C, D);
	setOutput(D, E);

	/*dummy values.*/
	/*fill vectors with values.*/

	fillWeights(A);
	copyWeightsToTexture(weight_matrix, A);
	copyMaskToTexture(mask_matrix, A);
	free(weight_matrix);
	free(mask_matrix);

	fillWeights(B);
	copyWeightsToTexture(weight_matrix, B);
	copyMaskToTexture(mask_matrix, B);
	free(weight_matrix);
	free(mask_matrix);

	fillWeights(C);
	copyWeightsToTexture(weight_matrix, C);
	copyMaskToTexture(mask_matrix, C);
	free(weight_matrix);
	free(mask_matrix);

	fillWeights(D);
	copyWeightsToTexture(weight_matrix, D);
	copyMaskToTexture(mask_matrix, D);
	free(mask_matrix);
	free(weight_matrix);

	/*Execute the network N times.*/
	while (n-->0){
		fillVector(A);
		/*glFinish(); //finish all operations before starting the clock*/
#ifdef WIN32
		QueryPerformanceCounter(&start);
#else
		start = clock();
#endif
		copyVectorToTexture(input, A);
		run(A);
		run(B);
		run(C);
		run(D);
		printLayer(E);
		/*glFinish(); //finish all operations before stopping the clock*/
#ifdef WIN32
		QueryPerformanceCounter(&end);
		QueryPerformanceFrequency( &freq );
		printf("Time in s:%f\n", ((double)(end.QuadPart - start.QuadPart))/(double)freq.QuadPart);
#else
		end = clock();
		run_time = (end-start)/CLOCKS_PER_SEC*1000;
		printf("Time in ms: %d\n", (int)run_time);
#endif
		free(input);
	}

	/*clean up*/
	destroyLayer(A);
	destroyLayer(B);
	destroyLayer(C);
	destroyLayer(D);
	destroyLayer(E);

	return 0;
}
Ejemplo n.º 13
0
TEST_F(Solver580DTest, Example3)
{
    setInput("2 2 0    100 0");
    Solver580D().run();
    EXPECT_EQ("100", getOutput());
}
Ejemplo n.º 14
0
TEST_F(Solver580DTest, Example1)
{
    setInput("2 2 1        1 1        2 1 1");
    Solver580D().run();
    EXPECT_EQ("3", getOutput());
}
Ejemplo n.º 15
0
void Pointer::setPointed(const Property *prop)
{
    setInput(prop);
}
Ejemplo n.º 16
0
TEST_F(Solver578BTest, Example2)
{
    setInput("4 2 3        1 2 4 8");
    Solver578B().run();
    EXPECT_EQ("79", getOutput());
}
Ejemplo n.º 17
0
Lexer::Lexer(std::istream &is)
{
	setInput(is);
}
Ejemplo n.º 18
0
TEST_F(Solver578BTest, Example3)
{
    setInput("1 10 8 1000000000");
    Solver578B().run();
    EXPECT_EQ("1073741824000000000", getOutput());
}
Ejemplo n.º 19
0
int main(int argc, char* argv[]) {
	int fd, fd2, retVal, t = 0, timeout = 1000;
	char buf[64];
	struct pollfd pollfd_a[1];
	unsigned char value;

	fd = open("/sys/class/gpio/export", O_WRONLY);
	write(fd, SDBOOT_GPIO, 2);
	write(fd, BOOTP_GPIO, 2);
	close(fd);
	setInput(SDBOOT_GPIO);
	setInput(BOOTP_GPIO);
	setEdgeRising(BOOTP_GPIO);

	if ((readValue(SDBOOT_GPIO) == '1') && (readValue(BOOTP_GPIO) == '0')) {
		sprintf(buf, "/sys/class/gpio/gpio%s/value", BOOTP_GPIO);
		fd = open(buf, O_RDONLY);
		read(fd, &value, 1);
		lseek(fd, 0, SEEK_SET);
		while (true) {
			memset((void *)pollfd_a, 0, sizeof(pollfd_a));
			pollfd_a[0].fd = fd;
			pollfd_a[0].events = POLLPRI;
			retVal = poll(pollfd_a, 1, timeout);
			if (retVal < 0) {
				printf("-ve return from poll\n");
				break;
			} else if (retVal == 0) {
				if (++t >= 10)
					break;
			} else {
				printf("+ve return from poll\n");
				if (pollfd_a[0].revents & POLLPRI)
					break;
			}
		}
		close(fd);
		if (retVal == 0) {
			fd = open("/sys/class/leds/whippet:red:armled0/trigger", O_WRONLY);
			fd2 = open("/sys/class/leds/whippet:red:armled1/trigger", O_WRONLY);
			write(fd, "timer", 5);
			write(fd2, "timer", 5);
			close(fd2);
			close(fd);
			fd = open(buf, O_RDONLY);
			read(fd, &value, 1);
			while(value == '0') {
				lseek(fd, 0, SEEK_SET);
				usleep(100);
				read(fd, &value, 1);
			}
			close(fd);
			printf("FRESET HAPPENING NOW!!!\n");
		} else
			printf("freset aborted\n");
	} else {
		printf("nothing doing\n");
		retVal = 1;
	}

	fd = open("/sys/class/gpio/unexport", O_WRONLY);
	write(fd, SDBOOT_GPIO, 2);
	write(fd, BOOTP_GPIO, 2);
	close(fd);

	return retVal;
}
Ejemplo n.º 20
0
SingleExtractor::SingleExtractor(const QString &input, const QString &output, const QString &metadata, ExtractionConfiguration *excfg) {
    setInput(input);
    setOutput(output);
    setMetadata(metadata);
    setConfiguration(excfg);
}
Ejemplo n.º 21
0
// Initialize the motor control.
void initMotorControl(void){
	// Set the directions.
	setOutput(DDRD, BRIDGE_A1);
	setOutput(DDRD, BRIDGE_A2);
	setOutput(DDRD, BRIDGE_A3);
	setOutput(DDRD, BRIDGE_A4);
	setOutput(DDRD, BRIDGE_EN);
	setInput(DDRD, MOTOR_L_A);
	setInput(DDRD, MOTOR_R_A);


	// Set the initial output values for outputs.
	setLow(PORTD, BRIDGE_A1);
	setHigh(PORTD, BRIDGE_A2);
	setLow(PORTD, BRIDGE_A3);
	setHigh(PORTD, BRIDGE_A4);
	setLow(PORTC, BRIDGE_EN);


	// Initilize Timer/counter 1
	TCCR1A = 0b10100010;
	TCCR1B = 0b00011001;
	// Both PMW outputs set at TOP, clear on compare
	// Waveform generation mode (WGM) set to 14 (fast PWM TOP is ICR1)
	// Input capture noise canceler (ICNC1) disabled, Input capture Edge select (ICES1) set to falling edge.
	// NOTE: when ICR1 is set to TOP the input capture function is disabled thus ICES1 and ICNC1 are cleared.
	// no prescaler is used clk/1

	TCNT1 = 0; 		//reset counter1
	OCR1A = 250; 	//speed of Left Motor 0-250
	OCR1B = 250; 	//speed of Right Motor 0-250
	ICR1 = 250; 	// Top value for TCNT1 defines the freq of the PMW (10MHz / 250 = 40 kHz)


	// Initilize Timer/Counter 0		
	TCCR0 = 0b00001101;
	// WGM CTC, OCR0 is TOP
	// OC0 disconnected.
	// clk/1024 prescaler = 9,765.625 Hz
	
	TCNT0 = 0;	// reset counter0
	OCR0 = 98;	// Counter divisor 9,765.625/98 = 99,64923469 Hz ~ 10 ms period

	// Enabled Timer/Counter0 Compare Match interrupt.
	TIMSK |= 2;


	// External interrupts... 
	//General Interrupt Control Register
	GICR |= 0b11000000;
	// bit 6 = 1 = Enable INT1
	// bit 7 = 1 = Enable INT0

	//MCU Control Register
	MCUCR |= 0b00001111;
	// bit1, bit0 = 11 = positive logical change on INT0 generates an interupt request.
	// bit3, bit2 = 11 = positive logical change on INT1 generates an interupt request

	//MSU Control and Status Register
	MCUCSR |= 0b00000000;

	// General Interrupt Flag Register
	GIFR   |= 0b11000000;
}
Ejemplo n.º 22
0
void CounterInterface::input()
{
    lItens->setStyleSheet("background-color: qlineargradient(spread:pad, x1:0.498,"
                          "y1:0, x2:0.494636, y2:1, stop:0 rgba(255, 255, 255, 210),"
                          "stop:0.982955 rgba(255, 255, 255, 170));"
                          "border-radius: 5px;border: 1px solid rgba(255,255,255,255);");

    pbSaveOrdered->setObjectName("pbSaveOrdered");
    pbSaveOrdered->setStyleSheet(this->styleSheet());
    pbSaveOrdered->setText(tr("Salvar"));
    pbSaveOrdered->setFont(this->font());
    pbSaveOrdered->setCursor(Qt::PointingHandCursor);

    pbRemoveItem->setObjectName("pbRemoveItem");
    pbRemoveItem->setStyleSheet(this->styleSheet());
    pbRemoveItem->setText(tr("Remover"));
    pbRemoveItem->setFont(this->font());
    pbRemoveItem->setCursor(Qt::PointingHandCursor);

    pbClearOrdered->setObjectName("pbClearOrdered");
    pbClearOrdered->setStyleSheet(this->styleSheet());
    pbClearOrdered->setText(tr("Limpar"));
    pbClearOrdered->setFont(this->font());
    pbClearOrdered->setCursor(Qt::PointingHandCursor);

    pbCancelOrdered->setObjectName("pbCancelOrdered");
    pbCancelOrdered->setStyleSheet(this->styleSheet());
    pbCancelOrdered->setText(tr("Cancelar"));
    pbCancelOrdered->setFont(this->font());
    pbCancelOrdered->setCursor(Qt::PointingHandCursor);

    pbConfirmProduct->setObjectName("pbConfirmProduct");
    pbConfirmProduct->setStyleSheet(this->styleSheet());
    pbConfirmProduct->setFont(this->font());
    pbConfirmProduct->setText(tr("Confirmar"));
    pbConfirmProduct->setCursor(Qt::PointingHandCursor);

    pbLeaveProduct->setObjectName("pbLeaveProduct");
    pbLeaveProduct->setStyleSheet(this->styleSheet());
    pbLeaveProduct->setFont(this->font());
    pbLeaveProduct->setText(tr("Limpar"));
    pbLeaveProduct->setCursor(Qt::PointingHandCursor);

    productPreview->setStyleSheet("background-color: rgba(0,0,0,0);"
                                  "color: rgba(255,255,255,240);");

    lPizza->setImage(":/treatment/icopizza");
    lPizza->setHover(":/treatment/icopizza-hover");

    sbAmount->setPrefix(tr("Quant "));
    sbAmount->setFont(this->font());
    sbAmount->setMinimum(1);
    sbAmount->setValue(1);
    sbAmount->setMaximum(99999);

    DSBValueProduct->setPrefix(tr("R$ "));
    DSBValueProduct->setMaximum(9999999);

    lProductNotes->setPixmap(QPixmap(":/treatment/field-notes-Background"));
    lTextNotesProduct->setText(tr("Anotações"));
    lTextNotesProduct->setFont(this->font());
    lTextNotesProduct->setAlignment(Qt::AlignHCenter);
    lTextNotesProduct->setStyleSheet("color: rgba(254, 255, 180, 255);");

    teProductNotes->setStyleSheet("background-color: qlineargradient"
                                  "(spread:pad, x1:0, y1:1, x2:0.165045,"
                                  "y2:0, stop:0 rgba(254, 255, 180, 255),"
                                  "stop:0.721591 rgba(255, 250, 205, 255));"
                                  "border-radius: 5px;border: 1px solid #C0C0C0;");

    teProductNotes->setFont(this->font());

    lProduct->setPixmap(QPixmap(":/treatment/fieldBackground"));
    lProduct->setScaledContents(true);

    QFont f;

#if defined(Q_WS_X11)
    f.setPointSize(9);
#endif

#if defined(Q_WS_WIN)
    f.setPointSize(12);
#endif

    productPreview->setFont(f);
    setPreview();

    tableItem->setModel(dataModelItems);

    wPizzaMixed->setFont(this->font());
    wPizzaMixed->setStyleSheet(this->styleSheet());

    searchProduct->setCompleter(order->bd.getCompleter("product"));

    cbSize->add("Tamanhos");

    actionName->setCheckable(true);
    actionName->setChecked(true);
    actionName->setEnabled(false);

    actionNickName->setCheckable(true);
    actionNickName->setChecked(false);
    actionNickName->setEnabled(true);

    searchProduct->setAction(actionName);
    searchProduct->setAction(actionNickName);

    searchProduct->eSearch->setNextComponent(cbSize);
    cbSize->setNextComponent(DSBValueProduct);
    DSBValueProduct->setNextComponent(sbAmount);

    emit setInput();
}
Ejemplo n.º 23
0
/**
 * colorMagnify	-	color magnification
 *
 */
void VideoProcessor::colorMagnify()
{
    // set filter
    setSpatialFilter(GAUSSIAN);
    setTemporalFilter(IDEAL);

    // create a temp file
    createTemp();

    // current frame
    cv::Mat input;
    // output frame
    cv::Mat output;
    // motion image

    cv::Mat motion;
    // temp image
    cv::Mat temp;

    // video frames
    std::vector<cv::Mat> frames;
    // down-sampled frames
    std::vector<cv::Mat> downSampledFrames;
    // filtered frames
    std::vector<cv::Mat> filteredFrames;

    // concatenate image of all the down-sample frames
    cv::Mat videoMat;
    // concatenate filtered image
    cv::Mat filtered;

    // if no capture device has been set
    if (!isOpened())
        return;

    // set the modify flag to be true
    modify = true;

    // is processing
    stop = false;

    // save the current position
    long pos = curPos;

    // jump to the first frame
    jumpTo(0);

    // 1. spatial filtering
    while (getNextFrame(input) && !isStop()) {
        input.convertTo(temp, CV_32FC3);
        frames.push_back(temp.clone());
        // spatial filtering
        std::vector<cv::Mat> pyramid;
        spatialFilter(temp, pyramid);
        downSampledFrames.push_back(pyramid.at(levels-1));
        // update process
        std::string msg= "Spatial Filtering...";
        emit updateProcessProgress(msg, floor((fnumber++) * 100.0 / length));
    }
    if (isStop()){
        emit closeProgressDialog();
        fnumber = 0;
        return;
    }
    emit closeProgressDialog();

    // 2. concat all the frames into a single large Mat
    // where each column is a reshaped single frame
    // (for processing convenience)
    concat(downSampledFrames, videoMat);

    // 3. temporal filtering
    temporalFilter(videoMat, filtered);

    // 4. amplify color motion
    amplify(filtered, filtered);

    // 5. de-concat the filtered image into filtered frames
    deConcat(filtered, downSampledFrames.at(0).size(), filteredFrames);

    // 6. amplify each frame
    // by adding frame image and motions
    // and write into video
    fnumber = 0;
    for (int i=0; i<length-1 && !isStop(); ++i) {
        // up-sample the motion image        
        upsamplingFromGaussianPyramid(filteredFrames.at(i), levels, motion);
	resize(motion, motion, frames.at(i).size());
        temp = frames.at(i) + motion;
        output = temp.clone();
        double minVal, maxVal;
        minMaxLoc(output, &minVal, &maxVal); //find minimum and maximum intensities
        output.convertTo(output, CV_8UC3, 255.0/(maxVal - minVal),
                  -minVal * 255.0/(maxVal - minVal));
        tempWriter.write(output);
        std::string msg= "Amplifying...";
        emit updateProcessProgress(msg, floor((fnumber++) * 100.0 / length));
    }
    if (!isStop()) {
        emit revert();
    }
    emit closeProgressDialog();

    // release the temp writer
    tempWriter.release();

    // change the video to the processed video
    setInput(tempFile);

    // jump back to the original position
    jumpTo(pos);
}
Ejemplo n.º 24
0
void DSMCall::setInputPlaylist() {
    DBG("setting playlist as input\n");
    setInput(&playlist);
}
Ejemplo n.º 25
0
int main(int argc, char **argv) {
    FILE * fr;
    char* fileInput = "test.csv";
    char * line = NULL;
    ssize_t read;
    size_t len = 0;
    int maxLines = -1;
    char* neurons = "100";
    char* netFile = "nets/digit_float_100.net";

    fann_type *calc_out;

    if(argc == 4) {
        fileInput = argv[1];
        maxLines = atoi(argv[2]);
        neurons = argv[3];
        netFile = (char*)malloc(strlen(netFile)+strlen(neurons)-2);
        strcpy(netFile,"nets/digit_float_");
        int i;
        for(i = 17; i < 17 + strlen(neurons); i++)
            netFile[i] = neurons[i - 17];
        netFile[i] = '.';
        netFile[i+1] = 'n';
        netFile[i+2] = 'e';
        netFile[i+3] = 't';
        netFile[i+4] = '\0';
    }

    //printf("File: %s\n",netFile);
    printf("ImageId,label\n");

    fr = fopen(fileInput, "r");
    int count = 0, ni = 0;
    while ((read = getline(&line, &len, fr)) != -1) {
        ni = count_commas(line) + 1;
        break;
    }
    fann_type *input = (fann_type*)malloc(sizeof(fann_type)*ni);
    count = 0;
    rewind(fr);

    struct fann *ann = fann_create_from_file(netFile);

    while ((read = getline(&line, &len, fr)) != -1) {
        if(count > 0) {
            setInput(input, line, ni);
            /*int i;
            for(i = 0;i < ni; i++)
            	printf("%0.0f ", input[i]);
            printf("\n");*/
            calc_out = fann_run(ann, input);
            //int n = sizeof(calc_out) / sizeof(calc_out[0]);
            int output = getMaxOutput(calc_out, 10);
            /*if((count -1) % 10 == 0)
            	printf("\n");
            printf("%d ", output);*/
            printf("%d,%d\n", count,output);
        }
        if(maxLines > 0 && count == maxLines)
            break;
        count++;
    }
    //printf("\n");
    fann_destroy(ann);
    return 0;
}
void AP_UnixDialog_GenericInput::eventOk()
{
	setInput(gtk_entry_get_text(GTK_ENTRY(m_wInput)));
}