在matlab中获取矩形块

时间:2015-08-10 17:42:22

标签: matlab

对于我的项目,我需要获取负样本的功能来训练分类器。我已经有了正面样本。这是我想要做的。

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

修改: 我有7481张分辨率为1224 * 370的图像和相应的标签文件(图像中对象的注释)。从标签上我得到width = 423.81 - 387.63 = 37height = 203.12 - 181.54 = 22。我想获得一个类似的块,不包括点423.81 - 387.63 = 37203.12 - 181.54 = 22。有人可以帮助我做到这一点。这是标签文件的结构。

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

编辑:我还有标签文件,其中有多个&#39; Car&#39;对象和没有“汽车”的地方宾语。这令我感到困惑。可以用一些草图伪代码

15列代表:

#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.

0 个答案:

没有答案