Git Product home page Git Product logo

Comments (49)

longzeyilang avatar longzeyilang commented on July 20, 2024 2

@meiqua LUT8_gen.cpp跑出LUT是:
uint8_t LUT_RIGHT[] = {0, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 4, 2, 4, 3, 4, 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
0, 3, 4, 4, 3, 3, 4, 4, 2, 3, 4, 4, 3, 3, 4, 4, 0, 1, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
0, 2, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 0, 2, 1, 2, 0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2,
0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 0, 3, 2, 3, 1, 3, 2, 3, 0, 3, 2, 3, 1, 3, 2, 3,
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 0, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 4, 2, 4, 3, 4,
0, 1, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 0, 3, 4, 4, 3, 3, 4, 4, 2, 3, 4, 4, 3, 3, 4, 4,
0, 2, 1, 2, 0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 2, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4,
0, 3, 2, 3, 1, 3, 2, 3, 0, 3, 2, 3, 1, 3, 2, 3, 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4};

不同于代码提供的:
static const unsigned char SIMILARITY_LUT[256] = {0, 4, 1, 4, 0, 4, 1, 4, 0, 4, 1, 4, 0, 4, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 1, ....
是否有问题?

from shape_based_matching.

Dyson-Ido avatar Dyson-Ido commented on July 20, 2024 1

@meiqua ,一直有个疑问,创建模板时为什么不提取一次特征点,其余的都通过旋转变换来获取呢,还要一张张旋转图片再去提取相应的特征点,谢谢!

from shape_based_matching.

JackLee1 avatar JackLee1 commented on July 20, 2024 1

谢谢,结合代码终于理解了ResponseMap数组的意思,就是取一个orientation,然后对orientation与各种orientation_i排列组合求余弦的绝对值的最大值,只不过最终的值为了计算方便用正整数代替而已。应该是这样理解的吧。

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

你是指加速的原理吗?大概来讲主要利用了降采样、方向量化、预计算得分、内存重新布局、SIMD加速。具体的话我也不会比linemod论文里讲的更好了。
如果是看不太懂论文,建议可以想想用普通的滑动窗口会怎么做;每一个加速方式可以说就是加速普通流程中的一个环节,大思路都是一样的。

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

经过测试,模板中有的边缘梯度,测试图像中除有模板有的,还有多余的东西,实际应该是NG,但是判定为OK,对于多余的,应该如何考虑?

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

不管多余的正是这个方法抗干扰的原因。如果必须没有多余的,由于位置已经确定,后面自己加一个筛选过程就行了

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

金字塔层数不对应,Detector默认是金字塔层数为2,步长[4,8],在match过程中,
for (int l = 0; l < pyramid_levels; ++l)
{
int T = T_at_level[l];
std::vector &lm_level = lm_pyramid[l];
if (l > 0) //l>0应该去除,i=0代表金字塔层1,i=1代表金字塔层2,以此类推
{
for(int i = 0; i < (int)quantizers.size(); ++i) quantizers[i]->pyrDown();
}
.......
}

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

这里是降采样,第一层不用,所以需要 l>0

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

matchClass()函数中关于int offset = lowest_T / 2 + (lowest_T % 2 - 1);中心点吗?
(x / T - 8 + best_c) * T + offset如何得来的?

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

是的,都是中心点。-8是因为第二层金字塔search的范围是16Tx16T,T是stride

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

第二层不是int lowest_T = T_at_level.back(); //8?
SIMILARITY_LUT是如何得到?

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

我说的第二层是T那个。
LUT就是把每种情况都算一遍。8位的LUT opencv只有结果,具体怎么得到的没有。不过我写过一个16位的:
16位LUT计算参考代码

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

static void spread(const Mat &src, Mat &dst, int T)中Fill in spread gradient image (section 2.3)是哪部分内容?对这部分不明白

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

对应论文3.3 就是方向扩散。一个地方可以最多容纳8个方向,预计算的时候找最近的方向比较作为得分

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024
    for (int c = 0; c < src.cols; ++c)
    {
        // Least significant 4 bits of spread image pixel
        lsb4_r[c] = src_r[c] & 15;           //左四位字节
        // Most significant 4 bits, right-shifted to be in [0, 16)
        msb4_r[c] = (src_r[c] & 240) >> 4;   //右四位字节
    }

为什么要这样分?

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

SIMD指令的限制,_mm_shuffle_epi8一次只能重排16个,所以只能4个字节一段来(2^4=16)

from shape_based_matching.

oUp2Uo avatar oUp2Uo commented on July 20, 2024

你好,请问下加上icp之后,怎样来计算模型是偏移了多少x/y呢?
比如之前可以用模板去和初始图匹配,得到一个match.x/y,然后再和目标图片匹配得到一个match.x/y,做差得到目标图偏移了多少的结果。
现在icp的结果是要把特征点算到图片位置上,再旋转+平移RegistrationResult的值。结果的角度确实可以直接用RegistrationResult给的,但是平移该怎么去计算修正值呢?谢谢

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@oUp2Uo 跟初始图match不太合适,信息已经存在template里了。其实用transform矩阵来看很清楚,整个过程有3步,每一步对于一个transform。第一步是旋转缩放,第二步是crop切黑边(相当于平移),第三步是icp精调,三步的矩阵乘起来角度、平移都有了。
我看这个大家问的比较多,这几天我写个文档说明下吧。

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

//src:1,2,4,8,16,32,64,128
static void spread(const Mat &src, Mat &dst, int T)
{
dst = Mat::zeros(src.size(), CV_8U);
/*
T={4,8}
以T=4为例
dst[0][0]=src[0][0]|src[0][1]|src[0][2]|src[0][3]|
src[1][0]|src[1][1]|src[1][2]|src[1][3]|
src[2][0]|src[2][1]|src[2][2]|src[2][3]|
src[3][0]|src[3][1]|src[3][2]|src[3][3]|
/
for (int r = 0; r < T; ++r)
for (int c = 0; c < T; ++c)
{
//src.step1():cols
channels
orUnaligned8u(&src.at(r, c), static_cast(src.step1()),
dst.ptr(),static_cast(dst.step1()), src.cols - c, src.rows - r);
}
}
对这部分还是不太理解

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

SIMILARITY_LUT怎么的出?能说说每个元素的意义吗?

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

这个很好理解,你可以反过来看src在dst的分布,比如src[0][0]在且仅在dst[0:4][0:4]有,这不就是想要的spread效果吗?(有一个2x2的小平移,不影响)
SIMILARITY_LUT在16位方向参考代码里写的很清楚了。
比如用8位方向来注释第24行:

    for(int i=0; i<8; i++){ // 8 ori
        for(int m=0; m<2; m++){ // 2 seg (2 segment of 4 bits)
            for(int n=0; n<16; n++){ // 16 index (2^4(4bits) = 16)   

// 8*2*16 = 256, that is SIMILARITY_LUT[256]

from shape_based_matching.

oUp2Uo avatar oUp2Uo commented on July 20, 2024

@oUp2Uo 跟初始图match不太合适,信息已经存在template里了。其实用transform矩阵来看很清楚,整个过程有3步,每一步对于一个transform。第一步是旋转缩放,第二步是crop切黑边(相当于平移),第三步是icp精调,三步的矩阵乘起来角度、平移都有了。
我看这个大家问的比较多,这几天我写个文档说明下吧。

嗯谢谢楼主。
我按照我前面说的那种方式(就是拿模板和初始图匹配得到一个初始偏移位置,再拿目标图去匹配的结果,求差得到结果),在加了icp之后,基本分值排名1-5的,其实角度差就在0.1范围内,证明icp效果很好……就是平移的那块,不知道怎么算了……

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@oUp2Uo 文档写好了

from shape_based_matching.

oUp2Uo avatar oUp2Uo commented on July 20, 2024

@oUp2Uo 文档写好了

感谢。
所以就是考虑模板的中心点的平移……我试试看看

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

icp不在cuda上运行可以吗?在cpu上运行的效率

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@longzeyilang 可以的,默认就是不开cuda。说不定cpu还快点,因为数据量很少,运行时间可能比传到gpu的overhead小。

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

@meiqua
我设置8个方向的代码,但是得到结果值与SIMILARITY_LUT[256]不一样,代码如下:
#include
#include
using namespace std;
/*
src在dst的分布,比如src[0][0]在且仅在dst[0:4][0:4]

  • */
    const int ORI=8; //8个方向
    const int SEG=2; //2个分割
    const int INDEX=16; //16索引
    struct Node {
    int value;
    int prev;
    int next;
    };

int main()
{
std::vector nodes(ORI);
for(int i=0; i<ORI; i++){
nodes[i].value = (1 << i);
nodes[i].prev = i-1;
nodes[i].next = i+1;
}
nodes[0].prev = ORI-1;
nodes[ORI-1].next = 0;

uint8_t LUT[ORI*SEG*INDEX] = {0};

for(int i=0; i<ORI; i++){ // 16 ori
    for(int m=0; m<SEG; m++){ // 4 seg
        for(int n=0; n<INDEX; n++){ // 16 index

            if(n==0){ // no ori
               LUT[n+m*INDEX+i*ORI*SEG] = 0;
               continue;
            }

            int res = (n << (m*SEG));
            auto current_node_go_forward = nodes[i];
            auto current_node_go_back = nodes[i];
            int angle_diff = 0;
            while(1){
                if((current_node_go_forward.value & res) > 0 ||
                   (current_node_go_back.value & res) > 0){
                    break;
                }else{
                    current_node_go_back = nodes[current_node_go_back.prev];
                    current_node_go_forward = nodes[current_node_go_forward.next];
                    angle_diff ++;
                }
            }
            LUT[n+m*ORI+i*ORI*SEG] = 4 - angle_diff;
        }
    }
}

for(int i=0; i<ORI; i++){
    for(int m=0; m<SEG*INDEX; m++){
        cout << int(LUT[i*SEG*INDEX + m]) << ", ";
    }
    cout << "\n";
}

return 0;

}

能帮我看看什么原因吗?

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

简单跑了下,LUT8_gen.cpp

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

KinectFusion: Real-time 3D Reconstruction and Interaction Using a Moving Depth Camera
搜索不到全文,能上传下吗?

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

楼主,我发现模板的宽度或者高度小于200,都训练失败,感觉训练成功根模板图像的尺寸有很大关系

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@longzeyilang 图像小了点数少选点就行了

from shape_based_matching.

longzeyilang avatar longzeyilang commented on July 20, 2024

如果单纯基于物体边缘轮廓进行定位匹配,能否给点意见?

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@longzeyilang 有什么问题吗?

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@longzeyilang 这里是之前测试的时候针对遮挡做的一点优化,具体原因可以参考这里

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@ScottYang1982 旋转量化前的应该也行。不过如果有尺度变化只能处理原图片

from shape_based_matching.

oUp2Uo avatar oUp2Uo commented on July 20, 2024

@ScottYang1982 旋转量化前的应该也行。不过如果有尺度变化只能处理原图片

你好,经过最近的实验,感觉在一个尺度下,直接旋转特征点的方式,会比较方便。
一是一组尺度下不需要再存这么多点了,只需要存一组数据,初始化的时候生成一遍就好。
二是对于模板的不需要的点的手动剔除也会方便很多。手动剔除了杂点之后,这个尺度的其他角度的不需要再次去重复操作了。否则如果旋转角度范围设置比较大时,手动剔除的操作比较繁琐。

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@oUp2Uo 是的,一个尺度下要好点

from shape_based_matching.

oUp2Uo avatar oUp2Uo commented on July 20, 2024

@oUp2Uo 是的,一个尺度下要好点

嗯,改了的话一个尺度只存一个,template id的存法、生成方法要修改。
然后如果要剔除杂点,还要改储存的数据结构,把点数也存到每一个template的属性里。
在弄这一块,但是没调过去还

from shape_based_matching.

JackLee1 avatar JackLee1 commented on July 20, 2024

meiqua:
能不能重新上传一下LUT8_gen.cpp文件,原链接已经无法打开。没有理解SIMILARITY_LUT是如何产生的,想查看下代码理解一下。

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@JackLee1 嗯,gist被墙了,可以参考这个

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@JackLee1 对的

from shape_based_matching.

pyni avatar pyni commented on July 20, 2024

您好,我向问一下

        const uchar *lut_low = SIMILARITY_LUT + 32 * ori;
        const uchar *lut_hi = lut_low + 16;

是啥意思,是不是在线性分配内存

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@pyni 不是的,只是确定下从哪读查找表

from shape_based_matching.

pyni avatar pyni commented on July 20, 2024

好的,多谢,请问目前的代码是不是只支持两层金字塔?(步长4和步长8)

from shape_based_matching.

meiqua avatar meiqua commented on July 20, 2024

@pyni 可以有多层

from shape_based_matching.

godlovehill avatar godlovehill commented on July 20, 2024

谢谢,结合代码终于理解了ResponseMap数组的意思,就是取一个orientation,然后对orientation与各种orientation_i排列组合求余弦的绝对值的最大值,只不过最终的值为了计算方便用正整数代替而已。应该是这样理解的吧。

请问每个像素的梯度方向一共有几种排列组合呢?

from shape_based_matching.

godlovehill avatar godlovehill commented on July 20, 2024

@meiqua 没看明白16位方向参考代码中的“2个分割”和“16索引”的含义,能否画个示意图解释下?

from shape_based_matching.

wly2020-robot avatar wly2020-robot commented on July 20, 2024

@oUp2Uo 文档写好了

感谢。 所以就是考虑模板的中心点的平移……我试试看看

请问中心点能平移跟踪吗?

from shape_based_matching.

zhenhuamo avatar zhenhuamo commented on July 20, 2024

你好,请问下加上icp之后,怎样来计算模型是偏移了多少x/y呢? 比如之前可以用模板去和初始图匹配,得到一个match.x/y,然后再和目标图片匹配得到一个match.x/y,做差得到目标图偏移了多少的结果。 现在icp的结果是要把特征点算到图片位置上,再旋转+平移RegistrationResult的值。结果的角度确实可以直接用RegistrationResult给的,但是平移该怎么去计算修正值呢?谢谢
@oUp2Uo 大佬,请问你知道经过icp 较准之后,怎样得到较准后,匹配结果,左上角的点的坐标吗?

from shape_based_matching.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.