Use Kinect LiDAR for camera matchmoving in PFTrack | 用Kinect的激光测距来帮助PFTrack的摄影机反求

So yea I got the idea becaues I wanted to deploy some close-up shots in my small project, but close-ups are always a pain to matchmove according to my experience. We know that this device’s resolution is quite limited, so does it work?

Couldn’t find anybody done the same thing using this low cost toy on Internet, or at least they didn’t post it. So here you go, the result turns out neat and I’m really happy with it. Notice at the end of the clip, the shot is pretty close and it worked fine. Video:


Youtube

所以我想用些近距离镜头但是tracking的问题很麻烦,不知道Kinect作为PFTrack的信息源行不行,网上也没人说(这个属于杀牛用鸡刀.. 专业的LiDAR三十万向上)只能自己实验了。试了一下结果很满意:



I used Skanec to generate the model and export it into a .ply file, then converted it to a .xyz file with some script, which was really easy and straightforward.

#include <iostream>
#include <fstream>

using namespace std;

int main() {
  fstream scene0;
  scene0.open("scene.txt");
  fstream scene1("./scene1.txt");

  while(!scene0.eof()) {

    char tmp[1000000];

    /*
    if(scene0.peek()>'9' || scene0.peek()<'0') {
      scene0.getline(tmp, 1000000);
      continue;
      }
    */

    int x,y,z;
    for(int i=0;i<3;i++) {
      double a;
      scene0 >> a;
      scene1<< a <<" ";
    }

    for(int i=0;i<3;i++) {
      double a;
      scene0 >> a;
    }

    for(int i=0;i<3;i++) {
      int a;
      scene0 >> a;
      scene1 << a << ' ';
    }
    
    scene0.getline(tmp, 1000000);
    scene1<<'\n';
  }

  scene0.close();
  scene1.close();
  
  return 0;
}


建模用的Skanect,写了个小脚本转换成带RGB的.xyz文件,很简单。(查了3天这格式到底是什么,终于有人提到和我猜的一样就是x y z r g b,最初不行只是要重新导一遍.. 泪)

#include <iostream>
#include <fstream>

using namespace std;

int main() {
  fstream scene0;
  scene0.open("scene.txt");
  fstream scene1("./scene1.txt");

  while(!scene0.eof()) {

    char tmp[1000000];

    /*
    if(scene0.peek()>'9' || scene0.peek()<'0') {
      scene0.getline(tmp, 1000000);
      continue;
      }
    */

    int x,y,z;
    for(int i=0;i<3;i++) {
      double a;
      scene0 >> a;
      scene1<< a <<" ";
    }

    for(int i=0;i<3;i++) {
      double a;
      scene0 >> a;
    }

    for(int i=0;i<3;i++) {
      int a;
      scene0 >> a;
      scene1 << a << ' ';
    }
    
    scene0.getline(tmp, 1000000);
    scene1<<'\n';
  }

  scene0.close();
  scene1.close();
  
  return 0;
}

5 thoughts on “Use Kinect LiDAR for camera matchmoving in PFTrack | 用Kinect的激光测距来帮助PFTrack的摄影机反求

  1. Pingback: Python初体验 / 把Kinect扫描的点云数据导入Maya « 成为酱油面的决心

  2. 趙偉雄

    你好,可不可以詳細說一下Kinect作为PFTrack的信息源的流程,我是來自澳門的~

    Reply
    1. Viaxl

      澳門的同學雷猴,流程大概是
      1. 看一下Skanect怎麼用的。
      2. 用Skanect掃描,把點雲導出為ply文件。
      3. 打開看一下ply格式是這樣的:
      [文件頭]
      X Y Z XN YN ZN R G B
      其中XN YN ZN是法線向量, 不需要。
      所以寫個腳本(比如我的)提取出X Y Z R G B 放到另外一個文件裡。
      4.用pftrack讀取。

      Reply

Leave a Reply to Viaxl Cancel reply

Your email address will not be published. Required fields are marked *