首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调整光流的帧大小

调整光流的帧大小
EN

Stack Overflow用户
提问于 2016-03-22 08:50:49
回答 1查看 1.2K关注 0票数 2

如果以任何方式操纵帧大小,我就会遇到光流问题,这会给我带来错误。有两个选项,要么在开始时改变视频的分辨率,要么以某种方式改变帧大小,使光流发挥作用。我想在进一步的开发中添加一个级联对象来检测鼻子,嘴巴和眼睛,因此我需要解决方案,该解决方案将适用于各个区域,而不需要为这些区域单独设置光流,特别是边界框没有固定的大小,它会从一帧到另一帧稍微移动。到目前为止,这是我的代码,错误是它超出了矩阵的维数。

代码语言:javascript
复制
faceDetector = vision.CascadeObjectDetector();

vidObj = vision.VideoFileReader('MEXTest.mp4','ImageColorSpace','Intensity','VideoOutputDataType','uint8');
converter = vision.ImageDataTypeConverter;
opticalFlow = vision.OpticalFlow('ReferenceFrameDelay', 1);
opticalFlow.OutputValue = 'Horizontal and vertical components in complex form';
shapeInserter = vision.ShapeInserter('Shape','Lines','BorderColor','Custom','CustomBorderColor', 255);
vidPlayer = vision.VideoPlayer('Name','Motion Vector');

while ~isDone(vidObj);
    frame = step(vidObj);
    fraRes = imresize(frame,0.5);
    fbbox = step(faceDetector,fraRes);

    I = imcrop(fraRes,fbbox); 

    im = step(converter,I);
    of = step(opticalFlow,im);
    lines = videooptflowlines(of, 20);
    if ~isempty(lines)
        out = step(shapeInserter,im,lines);
        step(vidPlayer,out);
    end
end
release(vidPlayer);
release(VidObj);
EN

回答 1

Stack Overflow用户

发布于 2016-04-01 06:01:22

更新:我去编辑了创建线条的光流函数,这解决了一些尺寸问题,但是有必要为每个对象手动输入(所以如果有任何其他方法,请让我知道)。我认为最好的解决方案是将cascadeObjectDetector设置为固定大小,有人知道怎么做吗?或者有其他想法吗?

代码语言:javascript
复制
faceDetector = vision.CascadeObjectDetector(); %I need fixed size for this
faceDetector.MinSize = [150 150];

vidRead = vision.VideoFileReader('MEXTest.mp4','ImageColorSpace','Intensity','VideoOutputDataType','uint8');
convert = vision.ImageDataTypeConverter; 
optFlo = vision.OpticalFlow('ReferenceFrameDelay', 1);
optFlo.OutputValue = 'Horizontal and vertical components in complex form';
shapeInserter = vision.ShapeInserter('Shape','Lines','BorderColor','Custom',  'CustomBorderColor', 255);

while ~isDone(vidRead)
    frame = step(vidRead);
    fraRes = imresize(frame,0.3);
    fraSin = im2single(fraRes);

    bbox = step(faceDetector,fraSin);

    I = imcrop(fraSin, bbox); 

    im = step(convert, I); 
    release(optFlo);
    of = step(optFlo, im);
    lines = optfloo(of, 50); %use videooptflowlines instead of (optfloo)
    out =  step(shapeInserter, im, lines); 
    imshow(out);
end
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36144348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档