Ask Your Question
2

Trouble Loading Caltech Data

asked 2017-08-22 16:36:13 -0600

l_grit gravatar image

Hi,

I have built the opencv_contrib repository from source along with the regular opencv repository. Following the information from this link http://docs.opencv.org/3.0-beta/modul... i have downloaded the caltech datasets. However when i try to run step 3 in the link i receive the following error:

./opencv/build/bin/example_datasets_pd_caltech -p=/home/prs/Documents/caltech_dataset/set00 * Error in `./opencv/build/bin/example_datasets_pd_caltech': double free or corruption (fasttop): 0x0000000001e3e3c0 * ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fe0d4a157e5] /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fe0d4a1e37a] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fe0d4a2253c] /home/prs/Downloads/opencv/opencv/build/lib/libopencv_datasets.so.3.3(_ZN2cv8datasets10getDirListERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIS6_SaIS6_EE+0x156)[0x7fe0d67040a6] /home/prs/Downloads/opencv/opencv/build/lib/libopencv_datasets.so.3.3(+0x4e945)[0x7fe0d66f6945] ./opencv/build/bin/example_datasets_pd_caltech[0x4010c3] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fe0d49be830] ./opencv/build/bin/example_datasets_pd_caltech(_start+0x29)[0x4012e9]

I was wondering if this is because example_datasets_pd_caltech wasn't built properly or i have conflicting libraries. Please let me know if you have an idea of hwo to fix this.

Thanks

edit retag flag offensive close merge delete

Comments

are you able to debug it ?

there might be indeed a bug here, when n<=0 (it probably should not free namelist then), see man page

berak gravatar imageberak ( 2017-08-23 00:50:01 -0600 )edit
1

I haven't been able to debug it... i'll let you know if I make any progress today UPDATE: i commented out the free(namelist) from util.cpp and it fixed the error. however I am getting a segmentation fault now.

./opencv/build/bin/example_datasets_pd_caltech -p=/home/prs/Documents/caltech_dataset/annotations/set00
train size: 15
first train object:
name: V000.vbb
images number: 0
Segmentation fault (core dumped)
l_grit gravatar imagel_grit ( 2017-08-23 08:12:02 -0600 )edit

how many classes the caltech have ? I saw where it was written. person/person?/person-fa/people . right ?

deeeepnet gravatar imagedeeeepnet ( 2018-03-10 02:27:44 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2017-08-23 13:34:02 -0600

updated 2017-08-23 13:44:19 -0600

below you can find modified version of pd_caltech.cpp (i added some code from library)

could you try it ( to investigate your problem and more importantly let us think about how to improve database module)

call it like

datasets-example-pd_caltech -p=E:/CaltechPedestrians/sets/set00/

pay attention / should be in end of path

if the code run for you without problem you will see images of database (without extracting all of them to Hard Disk

thank you in advance

#include "opencv2/datasets/pd_caltech.hpp"

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>

#include <iostream>
#include <cstdio>

#include <string>
#include <vector>

using namespace std;
using namespace cv;
using namespace cv::datasets;

Mat getImageFromSeq(String seqImagesPath, String seqName, int index);

int main(int argc, char *argv[])
{
    const char *keys =
            "{ help h usage ? |    | show this message }"
            "{ path p         |true| path to dataset }";
    CommandLineParser parser(argc, argv, keys);
    string path(parser.get<string>("path"));
    if (parser.has("help") || path=="true")
    {
        parser.printMessage();
        return -1;
    }

  //  Ptr<PD_caltech> dataset = PD_caltech::create();
  //  dataset->load(path);

    // ***************
    // dataset contains for each object its images.
    // currently on loading extract all images to folder path/../images/
    // For example, let output train size and first element of first object
    // and number of it's images.
  //  printf("train size: %u\n", (unsigned int)dataset->getTrain().size());

  //  PD_caltechObj *example = static_cast<PD_caltechObj *>(dataset->getTrain()[0].get());
   // printf("first train object:\n");
  //  printf("name: %s\n", example->name.c_str());
  //  printf("images number: %u\n", (unsigned int)example->imageNames.size());
  //  printf("first image name: %s\n", example->imageNames[0].c_str());
  //  printf("images were extracted to path/../images/\n");

    for (int i = 0; i < 100; i++)
    {
        Mat test = getImageFromSeq(path, "V000.seq", i);
        if (test.empty())
        {
            cout << "the specified file can't be opened, check the path";
            return 1;
        }
        imshow("Test", test);
        waitKey();
    }
    return 0;
}

Mat getImageFromSeq(String seqImagesPath, String seqName, int index)
{
    Mat image;
    int counter=0;
    FILE *f = fopen((seqImagesPath + seqName).c_str(), "rb");
    if (f != NULL)
    {
#define SKIP 28+8+512
        fseek(f, SKIP, SEEK_CUR);
        unsigned int header[9];
        size_t res = fread(header, 9, 4, f);
        double fps;
        res = fread(&fps, 1, 8, f);
        fseek(f, 432, SEEK_CUR);
        printf("width %u\n", header[0]);
        printf("height %u\n", header[1]);
        printf("imageBitDepth %u\n", header[2]);
        printf("imageBitDepthReal %u\n", header[3]);
        printf("imageSizeBytes %u\n", header[4]);
        printf("imageFormat %u\n", header[5]);
        printf("fps %f\n", fps);
        printf("trueImageSize %u\n", header[8]);
        unsigned int numFrames = header[6];
        printf("numFrames %u\n", numFrames);
        string ext;
        switch (header[5])
        {
        case 100:
        case 200:
            ext = "raw";
            break;
        case 101:
            ext = "brgb8";
            break;
        case 102:
        case 201:
            ext = "jpg";
            break;
        case 103:
            ext = "jbrgb";
            break;
        case 001:
        case 002:
            ext = "png";
            break;
        }

        for (unsigned int i = 0; i < numFrames; ++i)
        {
            unsigned int size;
            res = fread(&size, 1, 4, f);

            char imgName[20];
            sprintf(imgName, "/%u.%s", i, ext.c_str());

            // comment fseek and uncomment next block to unpack all frames
            if (index == counter)
            {
                char *img = new char[size];
                fread(img, size ...
(more)
edit flag offensive delete link more

Comments

Thank you, the code works! I was confused about the implementation of the pd_caltech example. Example code like this is perfect for getting a better understanding of the data-set module.

Again thank you so much!

l_grit gravatar imagel_grit ( 2017-08-23 14:06:24 -0600 )edit

i will try to update PD_caltech class soon. i think it need some improvement. if you need some further assistance. about the code in the answer don't hesitate to ask. thank you

sturkmen gravatar imagesturkmen ( 2017-08-23 14:11:40 -0600 )edit

for now it is not possible to get annotation values. i will search to find a way

sturkmen gravatar imagesturkmen ( 2017-08-23 14:13:58 -0600 )edit

How would I be able to extract the .vbb annotations in the caltech dataset?

l_grit gravatar imagel_grit ( 2017-08-23 14:18:38 -0600 )edit

why not? if you have MATLAB you can open them.their format is MATLAB 5.0 MAT-filei will try to find a way to read them. see https://stackoverflow.com/q/25810678/...

sturkmen gravatar imagesturkmen ( 2017-08-23 14:26:23 -0600 )edit

sorry, i meant is there a way to convert the .vbb files in c++?

l_grit gravatar imagel_grit ( 2017-08-23 14:35:27 -0600 )edit

it seems OpenCV has this feature but i did not use it before. i will take a look

sturkmen gravatar imagesturkmen ( 2017-08-23 14:43:06 -0600 )edit

why do you want to use Caltech Database ?

sturkmen gravatar imagesturkmen ( 2017-08-23 14:48:00 -0600 )edit

I am working on creating a pedestrian detector, however i would like to train the data myself. I read the caltech paper comparing various datasets and would like to use theirs.

l_grit gravatar imagel_grit ( 2017-08-23 14:52:42 -0600 )edit

Thank you, i will look into using that feature

l_grit gravatar imagel_grit ( 2017-08-23 14:54:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-22 16:36:13 -0600

Seen: 571 times

Last updated: Aug 23 '17