void Interpreter::controlKey(Qt::Key key)
{
    m_command = "";
    m_key = key;
    m_selection = RectA(0, 0, 0, 0);
    m_waitInput.wakeAll();
    if (m_programming)
        endLocalProgram();
}
void Interpreter::handleSelection(int x0, int y0, int width, int height)
{
    m_mutexInput.lock();
    m_command = QString::number(x0) + " " + QString::number(y0) +  " " + QString::number(width) +  " " + QString::number(height) + "\n";
    textOut(m_command);
    m_selection = RectA(x0, y0, width, height);
    m_key = (Qt::Key)0;
    m_waitInput.wakeAll();
    m_mutexInput.unlock();
}
void Interpreter::unwait()
{
    QMutexLocker locker(&m_mutexInput);
    if (m_waiting)
    {
        m_selection = RectA(0, 0, 0, 0);
        m_key = Qt::Key_Escape;
        m_waitInput.wakeAll();
        emit videoInput(VideoWidget::NONE);
    }
}
void Interpreter::command(const QString &command)
{
    QMutexLocker locker(&m_mutexInput);

    if (m_localProgramRunning)
        return;

    QStringList words = command.split(QRegExp("[\\s(),\\t]"), QString::SkipEmptyParts);

    if (m_waiting)
    {
        m_command = command;
        m_command.remove(QRegExp("[(),\\t]"));
        m_key = (Qt::Key)0;
        m_selection = RectA(0, 0, 0, 0);
        m_waitInput.wakeAll();
        goto end;
    }

    if (words.size()==0)
        goto end;

    if (words[0]=="do")
    {
        clearLocalProgram();
        beginLocalProgram();
    }
    else if (words[0]=="done")
    {
        endLocalProgram();
        locker.unlock();
        runOrStopProgram(true);
        locker.relock();
    }
    else if (words[0]=="list")
        listProgram();
    else if (words[0].left(4)=="cont")
    {
        locker.unlock();
        runOrStopProgram(true);
        locker.relock();
    }
    else if (words[0]=="close")
        queueCommand(CLOSE);
    else
        handleCall(words);
end:
    prompt();
}
Esempio n. 5
0
bool IterPixel::reset(bool cleari)
{
    if (cleari)
        m_i = 0;
    if (m_points)
    {
        if (m_points->size()>m_i)
        {
            m_region = RectA((*m_points)[m_i].m_x, (*m_points)[m_i].m_y, CL_GROW_INC, CL_GROW_INC);
            m_i++;
        }
        else
            return false; // empty!
    }
    m_x = m_y = 0;
    m_pixels = m_frame.m_pixels + (m_region.m_yOffset | 1)*m_frame.m_width + (m_region.m_xOffset | 1);
    return true;
}
// this routine assumes it can grab valid pixels in video memory described by the box
int32_t cc_setSigRegion(const uint32_t &type, const uint8_t &model, const uint16_t &xoffset, const uint16_t &yoffset, const uint16_t &width, const uint16_t &height)
{
	int result;
	char id[32];
	ColorModel cmodel;

	if (model<1 || model>NUM_MODELS)
		return -1;

	cc_setBounds(type);

	if (g_rawFrame.m_pixels==NULL)
	{
		cprintf("No raw frame in memory!\n");
		return -2;
	}

	// create lut
	result = g_blobs->generateLUT(model, g_rawFrame, RectA(xoffset, yoffset, width, height), &cmodel);
	if (result<0)
	{
		cprintf("Color saturation isn't high enough!\n");
		return result;
	}

	cmodel.m_type = type;

	// save to flash
	sprintf(id, "signature%d", model);
	prm_set(id, INTS8(sizeof(ColorModel), &cmodel), END);
	prm_setDirty(false); // prevent reload (because we don't want to load the lut (yet) and lose our frame

	cprintf("Success!\n");

	return result;
}