0

For my project I need to get features for negative samples to train the classifier. I already had positive samples. Here is what I am trying to do.

root_dir = '/home/shahnawaz/Downloads/test';
data_set = 'training';

%% get label directory
cam = 2; % 2 = left color camera
label_dir = fullfile(root_dir,[data_set '/label_' num2str(cam)]);
nlabels = length(dir(fullfile(label_dir, '*.txt')));

%% main loop
img_idx=0;
count = 1;
for lab_idx = 1:1:nlabels
    objects = readLabels(label_dir,lab_idx-1);
    for a = 1 :1:length(objects)
        s1 = objects(a).type;
        s2 = 'Car';
        cmp = strcmp(s1,s2);
        rear = (objects(a).alpha >= -pi/2+0.07) | (objects(a).alpha <=-pi/2-0.07); % get car with rear portion
        if (cmp )

        %% write your code.

        end
    end
end

EDIT: I have 7481 images with a resolution of 1224 * 370 and corresponding label files(annotation of objects in the image). From the label I get width = 423.81 - 387.63 = 37 and height = 203.12 - 181.54 = 22. I want to get a similar block excluding points 423.81 - 387.63 = 37 and 203.12 - 181.54 = 22 . Can someone help me do that. Here is the structure of the label file.

Truck 0.00 0 -1.57 599.41 156.40 629.75 189.25 2.85 2.63 12.34 0.47 1.49 69.44 -1.56
Car 0.00 0 1.85 387.63 181.54 423.81 203.12 1.67 1.87 3.69 -16.53 2.39 58.49 1.57
Cyclist 0.00 3 -1.65 676.60 163.95 688.98 193.93 1.86 0.60 2.02 4.59 1.32 45.84 -1.55
DontCare -1 -1 -10 503.89 169.71 590.61 190.13 -1 -1 -1 -1000 -1000 -1000 -10
DontCare -1 -1 -10 511.35 174.96 527.81 187.45 -1 -1 -1 -1000 -1000 -1000 -10
DontCare -1 -1 -10 532.37 176.35 542.68 185.27 -1 -1 -1 -1000 -1000 -1000 -10
DontCare -1 -1 -10 559.62 175.83 575.40 183.15 -1 -1 -1 -1000 -1000 -1000 -10

EDIT: I also have label file where I have more than one 'Car' object and where there is no 'Car' object. It is confusing me. Can some one sketch pseudo code

The 15 columns represent:

#Values    Name      Description
----------------------------------------------------------------------------
   1    type         Describes the type of object: 'Car', 'Van', 'Truck',
                     'Pedestrian', 'Person_sitting', 'Cyclist', 'Tram',
                     'Misc' or 'DontCare'
   1    truncated    Float from 0 (non-truncated) to 1 (truncated), where
                     truncated refers to the object leaving image boundaries
   1    occluded     Integer (0,1,2,3) indicating occlusion state:
                     0 = fully visible, 1 = partly occluded
                     2 = largely occluded, 3 = unknown
   1    alpha        Observation angle of object, ranging [-pi..pi]
   4    bbox         2D bounding box of object in the image (0-based index):
                     contains left, top, right, bottom pixel coordinates
   3    dimensions   3D object dimensions: height, width, length (in meters)
   3    location     3D object location x,y,z in camera coordinates (in meters)
   1    rotation_y   Rotation ry around Y-axis in camera coordinates [-pi..pi]
   1    score        Only for results: Float, indicating confidence in
                     detection, needed for p/r curves, higher is better.
shah
  • 311
  • 3
  • 20
  • 1
    "*I want to get get rectangle block excluding the rectangle block where there is a car.*".... http://i.imgur.com/TPHAplo.gif – rayryeng Aug 10 '15 at 17:49
  • I apologize if the question is misleading or confusing. I edited the question. Can you please check @rayryeng – shah Aug 10 '15 at 18:20
  • I still don't understand what you mean by "excluding". Excluding what from where? – beaker Aug 10 '15 at 18:27
  • I changed the question once more. "Excluding" means I need a random block in the image but it must overlap with the block which have a car label. I hope u will get it. – shah Aug 10 '15 at 18:37
  • In short, you need rectangular boxes from an image which belong to a negative class. In your problem, negative class is - "not a car". Just sample boxes randomly, or by using some object proposal technique (like BING, EdgeBoxes). Then remove those boxes which intersect with boxes having a positive label (or are truncated, occluded etc.). The removal of truncated objects will depend on your method. If I were you and using a basic object detection method, I would probably remove such boxes. – Autonomous Aug 10 '15 at 18:38
  • thank you so much. I am cursing myself what I asked. I just need one random rectangular box per image. and yes negative class means "not a car" 2 – shah Aug 10 '15 at 18:41
  • 1
    [This](http://stackoverflow.com/a/13390495/1586200) and some technique to generate boxes randomly is all you need. Note this: you don't need one rectangular box per image. To detect all cars in an image, you would need 10000s of boxes if you are choosing randomly. If you are using some method like BING, EdgeBoxes, Selective search, you need at least 1000 to be sure. – Autonomous Aug 10 '15 at 18:42
  • yeah I believe. let me try. And this is one my negative sample and I don't want to include "Car" in that as I already had positive sample for car – shah Aug 10 '15 at 18:45
  • I have edited the question. can you please layout a sketch @ParagS.Chandakkar – shah Aug 11 '15 at 10:54

0 Answers0