Exemple #1
0
int main(int argc, char** args) {
    if(fileExists("camera.xml")) {
        camSettings = loadCameraSettings((char*)"camera.xml");
    }
    if(fileExists("object.xml")) {
        objInfo = loadObjectInfo((char*)"object.xml");
    }

#ifdef NIX
    disableAutoExposure();
#endif

    if(argc > 1) {
        preferenceFileName = args[1];
    }

    VideoCapture capture(CAMERA_ID);
    if (!capture.isOpened()) {
        cerr << "Failed to open camera!" << endl;
        return 1;
    }

    //Set camera properties
    if(camSettings.gain != -1) {
        capture.set(CV_CAP_PROP_GAIN, camSettings.gain);
    }
    if(camSettings.exposureTime != -1) {
        capture.set(CV_CAP_PROP_EXPOSURE, camSettings.exposureTime);
    }

    return process(capture);
}
Exemple #2
0
void ConfigParser::parseConfigFile()
{
    loadObjectList();
    for (auto obj_name : object_list_)
        loadObjectInfo(obj_name);
}
QTreeWidgetItem* GCF::Components::ScriptableObjectExplorerData::loadObjectInfo(QTreeWidget* treeWidget, QTreeWidgetItem* item, QObject* object, QString name, bool showChildren)
{
    if(!object)
        return 0;

    if(!treeWidget && !item)
        return 0;

    static QColor eventColor = Qt::black;
    static QColor propertyColor = Qt::black;
    static QColor methodColor = Qt::black;

    if(name.isEmpty())
        name = object->objectName();
    if(name.isEmpty())
        return 0;

    // add the object item
    QTreeWidgetItem* objectItem = 0;
    if(item)
        objectItem = new QTreeWidgetItem(item, OBJECT_ITEM);
    else
        objectItem = new QTreeWidgetItem(treeWidget, OBJECT_ITEM);
    objectItem->setText(0, name);
    objectItem->setData(0, Qt::UserRole, qVariantFromValue<QObject*>(object));
    objectItem->setText(1, name);
    objectItem->setIcon(0, objectPm);
    objectItems.append(objectItem);

    QTreeWidgetItem* eventItem = new QTreeWidgetItem(objectItem, QStringList() << "Events");
    QTreeWidgetItem* methodItem = new QTreeWidgetItem(objectItem, QStringList() << "Methods");
    QTreeWidgetItem* propertyItem = new QTreeWidgetItem(objectItem, QStringList() << "Properties");
    QTreeWidgetItem* childrenItem = new QTreeWidgetItem(objectItem, QStringList() << "Children");

    eventItem->setIcon(0, eventPmDir);
    methodItem->setIcon(0, methodPmDir);
    propertyItem->setIcon(0, propertyPmDir);
    childrenItem->setIcon(0, propertyPmDir);

    // add items.
    const QMetaObject* mo = object->metaObject();
    for(int j=QObject::staticMetaObject.methodCount(); j<mo->methodCount(); j++)
    {
        QMetaMethod m = mo->method(j);
        QTreeWidgetItem* item =  0;

        switch(m.methodType())
        {
        case QMetaMethod::Signal: {
            item = new QTreeWidgetItem(eventItem, EVENT_ITEM);
            item->setIcon(0, eventPm);
            QString event = formattedName(m.signature());
            item->setText(0, event);
            item->setData(0, Qt::ForegroundRole, eventColor);
            } break;
        case QMetaMethod::Method:
        case QMetaMethod::Slot:
        default: {
            if(m.access() != QMetaMethod::Public)
                break;
            item = new QTreeWidgetItem(methodItem, METHOD_ITEM);
            item->setIcon(0, methodPm);
            QString methodName = QString(m.signature()).section('(', 0, 0);
            item->setText(0, methodName);
            item->setData(0, Qt::ForegroundRole, methodColor);
            } break;
        }

        if(item)
            item->setData(0, Qt::UserRole, qVariantFromValue<QMetaMethod>(m));
    }

    for(int j=QObject::staticMetaObject.propertyCount(); j<mo->propertyCount(); j++)
    {
        QMetaProperty prop = mo->property(j);
        QTreeWidgetItem* item = new QTreeWidgetItem(propertyItem, PROPERTY_ITEM);
        item->setIcon(0, propertyPm);
        item->setData(0, Qt::UserRole, qVariantFromValue<QMetaProperty>(prop));
        item->setData(0, Qt::ForegroundRole, propertyColor);
        item->setText(0, prop.name());
    }

    if(showChildren)
    {
        QObjectList children = object->children();
        for(int i=0; i<children.count(); i++)
        {
            QObject* childObject = children[i];
            QString childName = QString("%1.%2").arg(name).arg(childObject->objectName());
            loadObjectInfo(treeWidget, childrenItem, childObject, childName, showChildren);
        }
    }

    objectItem->setExpanded(false);

    if(eventItem->childCount())
        eventItem->setExpanded(false);
    else
        delete eventItem;

    if(methodItem->childCount())
        methodItem->setExpanded(false);
    else
        delete methodItem;

    if(propertyItem->childCount())
        propertyItem->setExpanded(false);
    else
        delete propertyItem;

    if(childrenItem->childCount())
        childrenItem->setExpanded(false);
    else
        delete childrenItem;

    return objectItem;
}