Ask Your Question

rawesfa's profile - activity

2013-05-25 06:54:58 -0600 commented answer Retina Demo - segmentation fault

displaying image with imshow works well. so if it works for you with createRetina(), then there is a problem when creating myRetina. btw. where did you get 2.4.9, when the newest is 2.4.5 on opencv.org?

2013-05-25 06:16:08 -0600 received badge  Editor (source)
2013-05-25 06:14:59 -0600 commented answer Retina Demo - segmentation fault

you are right, that was just my sloppiness to make things faster. anyway, i still get segmentation fault.

2013-05-25 04:20:29 -0600 asked a question Retina Demo - segmentation fault

Hello, I'm trying to run tutorial code from opencv 2.4.5 to retina model and after my little modification it goes like that:

#include <iostream>
#include <cstring>

#include "opencv2/opencv.hpp"

using namespace cv;

static void help(std::string errorMessage)
{
    std::cout<<"Program init error : "<<errorMessage<<std::endl;
    std::cout<<"\nProgram call procedure : retinaDemo [processing mode] [Optional : media target] [Optional LAST parameter: \"log\" to activate retina log sampling]"<<std::endl;
    std::cout<<"\t[processing mode] :"<<std::endl;
    std::cout<<"\t -image : for still image processing"<<std::endl;
    std::cout<<"\t -video : for video stream processing"<<std::endl;
    std::cout<<"\t[Optional : media target] :"<<std::endl;
    std::cout<<"\t if processing an image or video file, then, specify the path and filename of the target to process"<<std::endl;
    std::cout<<"\t leave empty if processing video stream coming from a connected video device"<<std::endl;
    std::cout<<"\t[Optional : activate retina log sampling] : an optional last parameter can be specified for retina spatial log sampling"<<std::endl;
    std::cout<<"\t set \"log\" without quotes to activate this sampling, output frame size will be divided by 4"<<std::endl;
    std::cout<<"\nExamples:"<<std::endl;
    std::cout<<"\t-Image processing : ./retinaDemo -image lena.jpg"<<std::endl;
    std::cout<<"\t-Image processing with log sampling : ./retinaDemo -image lena.jpg log"<<std::endl;
    std::cout<<"\t-Video processing : ./retinaDemo -video myMovie.mp4"<<std::endl;
    std::cout<<"\t-Live video processing : ./retinaDemo -video"<<std::endl;
    std::cout<<"\nPlease start again with new parameters"<<std::endl;
    std::cout<<"****************************************************"<<std::endl;
    std::cout<<" NOTE : this program generates the default retina parameters file 'RetinaDefaultParameters.xml'"<<std::endl;
    std::cout<<" => you can use this to fine tune parameters and load them if you save to file 'RetinaSpecificParameters.xml'"<<std::endl;
}

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;
        }
    else
        {
            help("bad command parameter");
            return -1;
        }
    }
    if (inputFrame.empty())
    {
        help("Input media could not be loaded, aborting");
        return -1;
    }

    try
    {
        // create a retina instance with default parameters setup, uncomment the initialisation you wanna test
        Ptr<Retina> myRetina;

        // if the last parameter is 'log', then activate log sampling (favour foveal vision and subsamples peripheral vision)
        if (useLogSampling)
        {
             myRetina = new cv::Retina(inputFrame.size(), true, cv::RETINA_COLOR_BAYER, true, 2.0, 10.0);
        }
        else// -> else ...
(more)