将Matlab pdollar工具箱代码转换为Octave后读取框架 [英] Reading frame after converting Matlab pdollar toolbox code to Octave

查看:296
本文介绍了将Matlab pdollar工具箱代码转换为Octave后读取框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用pdollar工具箱阅读视频。我有几个视频文件,我试图应用acfDetect分类器。但是,我没有得到正确的输出。在检查时,我发现对于Matlab和Octave,帧(矩阵)的数据不匹配。随附的照片将清楚这个问题。我试图打印框架的值,这就是我得到的:

I want to read a video using pdollar toolbox. I have few video files upon whom I am trying to apply the acfDetect classier. However, I don't get the correct output. On checking, I found that the data of the frame (the matrix) do not match, for Matlab and Octave. The question will be clear with the attached pics. I tried to print the value of the frame and this is what I get:

Matlab输出:

< a href =https://i.stack.imgur.com/K7FQb.png =nofollow noreferrer>

八度输出:

作为一个试验,我看到将Octave值乘以255(RGB max)给出了一个近似于Matlab的值。但是当我这样做时,我收到以下错误:

As a hit an trial, I saw that multiplying Octave values by 255 (RGB max) gives me an approx to the Matlab values. But when I do so, I get the following error:

> >> runonVideos
处理11-50-48--11-50-58_resized.mp4 ...
错误:rgbConvertMex:对于浮点数,I中的所有值必须小于1.
错误:调用来自
rgbConvert第80行第2列
chnsPyramid第133行第2列
acfDetect_modified> acfDetectImg第74行第2列
acfDetect_modified第41行第19行
行人在线检测33列11
runonVideos第8行第5列

基本上,Matlab得到相同的值(0-255)但不是'为这里所述的函数给出任何这样的错误:rgbConvertMex。我无法理解问题究竟在哪里。

Essentially, Matlab gets the same value (0-255) but doesn't give any such error for the function stated here: rgbConvertMex.I am unable to understand where exactly is the problem.

如果我能得到与Matlab,我的问题将在很大程度上得到解决。

If I am able to get the same value as in Matlab, my problem will be solved to a large extent.

Octave代码在这里:

The Octave code is here:

> % Output text file
    outFile = fopen(['C:\devwork\matlab\boosted\detection\',videoFname(1:end-4),'_detections.txt'],'w+');
    % videoPlayer = vision.VideoPlayer;
    vObj = VideoReader('C:\devwork\matlab\boosted\resizedVideos\11-50-48--11-50-58_resized.mp4');
    %fprintf vObj;
    % videoFwriter = vision.VideoFileWriter('result3_newAnnLdcf+.mp4','FileFormat','MPEG4','FrameRate',vObj.FrameRate);
    tic
    while hasFrame(vObj)

        frame = readFrame(vObj);
        %fprintf(frame);
        % frame = imresize(frame,0.5);
        bbs = acfDetect_modified(frame,detector);
        % displayFrame = frame;
        bbs = bbs(:,1:4);
        bbs = round(bbs);
%         if ((bbs(1,:) >= 1152) || (bbs(2,:) >= 648))
%             disp('BB exceeds bounds')
%             disp(bbs)
%         end
        % displayFrame = insertShape(displayFrame,'Rectangle',bbs,'LineWidth',2,'Color','red'); 
        fprintf(outFile,'%d ',reshape(bbs,numel(bbs),1));
        fprintf(outFile,'\n');
        % videoPlayer.step(displayFrame);
        % step(videoFwriter,displayFrame);
    end
    toc
    fclose(outFile);
    fprintf('done \n');
    % release(videoPlayer);
    % release(videoFwriter);
end

编辑1:在Matlab中,我尝试将v = v * 255更改为v = uint8(v)
但现在我将所有值都设为0或1.

Edit 1: In Matlab, I tried changing v=v*255 to v=uint8(v) But now I get all values as either 0 or 1.

编辑2:

代码截图:

Screenshot of the code:

输出屏幕截图:

编辑3:根据建议,Octace中的代码行31更改为: v = uint8(v * 255 );
这确实给出了整数的结果,但它们仍然与Matlab的结果不同。我猜它一定是我的乘法因子为255的问题。但是这仍然没有解决。

Edit 3: As suggested, code line 31 in Octace was changed to:v=uint8(v*255); This does give result in integers but they are still not same as that of Matlab. I am guessing it must be some issue with my multiplication factor of 255. But this is still not resolved.

新输出的屏幕截图:

推荐答案

您正在寻找的功能是 im2uint8 ,由图像包提供。

The function you're looking for is im2uint8, which is provided by the image package.

这可以输入类在[0,1]范围内加倍并将其转换为uint8图像,相应的值在[0,255]范围内。

This can take an input of class double in the range [0,1] and convert it to a uint8 image, with corresponding values in the range [0,255] accordingly.

这篇关于将Matlab pdollar工具箱代码转换为Octave后读取框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆