Exemple #1
0
        Camera(pugi::xml_node &camera)
        {
            cfa = newiPoint2D(0, 0);
            pugi::xml_attribute key = camera.attribute("make");
            if (!key)

                ThrowCME("Camera XML Parser: \"make\" attribute not found.");
            make = canonical_make = key.as_string();

            key = camera.attribute("model");
            if (!key)

                ThrowCME("Camera XML Parser: \"model\" attribute not found.");
            model = canonical_model = canonical_alias = key.as_string();

            canonical_id = make + " " + model;

            supported = true;
            key = camera.attribute("supported");
            if (key)
            {
                string s = string(key.as_string());
                if (s.compare("no") == 0)
                    supported = false;
            }

            key = camera.attribute("mode");
            if (key)
            {
                mode = key.as_string();
            }
            else
            {
                mode = string("");
            }

            key = camera.attribute("decoder_version");
            if (key)
            {
                decoderVersion = key.as_int(0);
            }
            else
            {
                decoderVersion = 0;
            }

            for (xml_node node = camera.first_child(); node; node = node.next_sibling())
            {

                parseCameraChild(node);
            }
        }
Exemple #2
0
void parseCameraChild(xml_node &cur)
{
    if (isTag(cur.name(), "CFA"))
    {
        if (2 != cur.attribute("width").as_int(0) || 2 != cur.attribute("height").as_int(0))
        {
            supported = false;
        }
        else
        {
            cfa.setSize(iPoint2D(2, 2));
            xml_node c = cur.child("Color");
            while (c != null)
            {
                parseCFA(c);
                c = c.next_sibling("Color");
            }
        }
        return;
    }

    if (isTag(cur.name(), "CFA2"))
    {
        cfa.setSize(iPoint2D(cur.attribute("width").as_int(0), cur.attribute("height").as_int(0)));
        xml_node c = cur.child("Color");
        while (c != null)
        {
            parseCFA(c);
            c = c.next_sibling("Color");
        }
        c = cur.child("ColorRow");
        while (c != null)
        {
            parseCFA(c);
            c = c.next_sibling("ColorRow");
        }
        return;
    }

    if (isTag(cur.name(), "Crop"))
    {
        cropPos.x = cur.attribute("x").as_int(0);
        cropPos.y = cur.attribute("y").as_int(0);

        if (cropPos.x < 0)
            ThrowCME("Negative X axis crop specified in camera %s %s", make.c_str(), model.c_str());
        if (cropPos.y < 0)
            ThrowCME("Negative Y axis crop specified in camera %s %s", make.c_str(), model.c_str());

        cropSize.x = cur.attribute("width").as_int(0);
        cropSize.y = cur.attribute("height").as_int(0);
        return;
    }

    if (isTag(cur.name(), "Sensor"))
    {
        parseSensorInfo(cur);
        return;
    }

    if (isTag(cur.name(), "BlackAreas"))
    {
        xml_node c = cur.first_child();
        while (c != null)
        {
            parseBlackAreas(c);
            c = c.next_sibling();
        }
        return;
    }

    if (isTag(cur.name(), "Aliases"))
    {
        xml_node c = cur.child("Alias");
        while (c != null)
        {
            parseAlias(c);
            c = c.next_sibling();
        }
        return;
    }

    if (isTag(cur.name(), "Hints"))
    {
        xml_node c = cur.child("Hint");
        while (c != null)
        {
            parseHint(c);
            c = c.next_sibling();
        }
        return;
    }

    if (isTag(cur.name(), "ID"))
    {
        parseID(cur);
        return;
    }
}