如果以任何方式操纵帧大小,我就会遇到光流问题,这会给我带来错误。有两个选项,要么在开始时改变视频的分辨率,要么以某种方式改变帧大小,使光流发挥作用。我想在进一步的开发中添加一个级联对象来检测鼻子,嘴巴和眼睛,因此我需要解决方案,该解决方案将适用于各个区域,而不需要为这些区域单独设置光流,特别是边界框没有固定的大小,它会从一帧到另一帧稍微移动。到目前为止,这是我的代码,错误是它超出了矩阵的维数。
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);发布于 2016-04-01 06:01:22
更新:我去编辑了创建线条的光流函数,这解决了一些尺寸问题,但是有必要为每个对象手动输入(所以如果有任何其他方法,请让我知道)。我认为最好的解决方案是将cascadeObjectDetector设置为固定大小,有人知道怎么做吗?或者有其他想法吗?
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);
endhttps://stackoverflow.com/questions/36144348
复制相似问题