Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

oh, you can't modify argv !

either supply the required args on the cmdline (and leave the original argv-code intact)

or replace all occurences with "real" strings

oh, you can't modify argv !

either supply the required args on the cmdline (and leave the original argv-code intact)

or replace all occurences with "real" strings

int main(int argc, char* argv[]) {
    bool useLogSampling = false; // "log" // check if user wants retina log sampling processing
    std::string inputMediaType="-image"; // argv[1]
    string imageOrVideoName = "lenka.jpg"; // argv[2]


    // declare the retina input buffer... that will be fed differently in regard of the input media
    Mat inputFrame, image;
    VideoCapture videoCapture; // in case a video media is used, its manager is declared here

    if (!strcmp(inputMediaType.c_str(), "-image") )
    {
        std::cout<<"RetinaDemo: processing image "<<imageOrVideoName<<std::endl;
        inputFrame = imread(imageOrVideoName, 0); // load image in RGB mode
    }else{
        if (!strcmp(inputMediaType.c_str(), "-video"))
        {
            if (useLogSampling) // attempt to grab images from a video capture device
            {
                videoCapture.open(0);
            }else// attempt to grab images from a video filestream
            {
                std::cout<<"RetinaDemo: processing video stream "<<imageOrVideoName<<std::endl;
                videoCapture.open(imageOrVideoName);
            }
            // grab a first frame to check if everything is ok
            videoCapture>>inputFrame;
        }
    }

oh, you can't must not modify argv argc/argv ! (if you did not supply args there, argv[] only holds 1 string, the progname. assigning to argv[1], argv[2] or such will overflow, and invoke nasal demons! )

either supply the required args on the cmdline (and leave the original argv-code intact)

or replace all occurences with "real" strings

int main(int argc, char* argv[]) {
    bool useLogSampling = false; // "log" // check if user wants retina log sampling processing
    std::string inputMediaType="-image"; // argv[1]
    string imageOrVideoName = "lenka.jpg"; // argv[2]


    // declare the retina input buffer... that will be fed differently in regard of the input media
    Mat inputFrame, image;
    VideoCapture videoCapture; // in case a video media is used, its manager is declared here

    if (!strcmp(inputMediaType.c_str(), "-image") )
    {
        std::cout<<"RetinaDemo: processing image "<<imageOrVideoName<<std::endl;
        inputFrame = imread(imageOrVideoName, 0); // load image in RGB mode
    }else{
        if (!strcmp(inputMediaType.c_str(), "-video"))
        {
            if (useLogSampling) // attempt to grab images from a video capture device
            {
                videoCapture.open(0);
            }else// attempt to grab images from a video filestream
            {
                std::cout<<"RetinaDemo: processing video stream "<<imageOrVideoName<<std::endl;
                videoCapture.open(imageOrVideoName);
            }
            // grab a first frame to check if everything is ok
            videoCapture>>inputFrame;
        }
    }