ermig1979 / Simd

C++ image processing and machine learning library with using of SIMD: SSE, AVX, AVX-512, AMX for x86/x64, VMX(Altivec) and VSX(Power7) for PowerPC, NEON for ARM.
http://ermig1979.github.io/Simd
MIT License
2.04k stars 407 forks source link

about shift detector accuracy #146

Closed axllou closed 3 years ago

axllou commented 3 years ago

Hi, I tried shift detector for analyzing motion flow in the image. First I set a target ROI, then I find sometimes I got accurate result, but sometimes I got (0,0) motion vector if I slightly adjust the target ROI a little bit. Is the resolution of image not to be too small? I use 320x192 for the images. Or any parameters needs to be tuned? Thanks.

ermig1979 commented 3 years ago

Hi! Would you get me code example of using of Simd::ShiftDetector . It helps me to give you more detail answer.

axllou commented 3 years ago

Hi, I think my usage is almost the same as the example shown in SimdShift.hpp. The only difference is I use two different but consecutive images instead of the same image but shifted (10, 10) in the example.

The pseudo code is like: typedef Simd::ShiftDetector ShiftDetector; ShiftDetector::View background(src1_width, src1_height, src1_stride, ShiftDetector::View::Gray8, src1_addr);
ShiftDetector::View current(src2_width, src2_height, src2_stride, ShiftDetector::View::Gray8, src2_addr);
ShiftDetector::View current_crop;

ShiftDetector detector;
detector.InitBuffers(background.Size(), pyramid_level);
detector.SetBackground(background, 0);

ShiftDetector::Rect region;
region.SetTop(u16Top);
region.SetBottom(u16Top + u16Height - 1);
region.SetLeft(u16Left);
region.SetRight(u16Left + u16Width - 1);
current_crop = current.Region(region);

if (detector.Estimate(current_crop, region, search_range))
{
    mv_x = detector.Shift().x;
    mv_y = detector.Shift().y;
} else
{
    mv_x = 0;
    mv_y = 0;
}
ermig1979 commented 3 years ago

There are notes:

1) Rect initialization:

ShiftDetector::Rect region;
region.SetTop(u16Top);
region.SetBottom(u16Top + u16Height);
region.SetLeft(u16Left);
region.SetRight(u16Left + u16Width);

2) background.Size() != ?, pyramid_level = ?, search_range = ?, region = ?