Vot toolkit for python tracker(转)

issues and possbile solutions to integrate python-based tracker on Ubuntu

I tried to integrate my python-implemented into the vot-2017 evaluation toolkit on Ubuntu 16.04. However, I encountered several issues, and it took much time for me to solve these issues, since I could hardly find any possible solutions from Google.

 

So, I post these issues and my possible solutions here. Hope this can help you to save your time.

 

1.     Matlab mex compiling, and GCC?

The first time you run the run_xxx command, the VOT toolkit will try to download (before vot-2017) or compile (vot-2017) the native tools which will be used to accelerate the evaluation or communicate with the tested trackers via the trax protocol. The latest gcc compiler that matlab (R2016b) supported for the mex compiling is GCC 4.9. However, the supported compiler is probably not installed in Ubuntu, in which case you will receive a warning saying that the gcc compiler found is not supported. Fortunately, the mex can still work with the system-provided gcc. But, when you call the mex-compiled function in matlab, you will probably encounter a runtime library error saying that there is something wrong with the standard C runtime library.

 

This issue is raised because the matlab use different standard C runtime libraries when compiling via mex and running the mex-compiled function. The system-provided GCC is used to compile, but the compiled function is linked to a different GCC runtime library that is bundled with matlab.

 

My simple solution to this issue is that, we can simply disable the gcc library bundled with matlab by renaming the soft symbol link to the library:

            cd  MATLAB_ROOT/sys/os/glnxa64

            mv  libstdc ++.so.6  libstdc++.so.6.bak

 

Anytime you find there is something wrong with the library, you can rename it back.

 

2.     Runtime library for your tracker not found?

It is very common for pythoners to run their code in a separate virtual environment. In my case, I installed anaconda (the most popular python distribution for pythoners), and created a separate conda environment for my tracker.

 

Following the instructions provided by the official support page to integrate your python-based tracker, you will probably encounter import error or runtime-library-not-found error. You need to do a litter more work in addition to what the official tutorial told you.

 

First, you need to specify your python interpreter in the tracker_xxx.m file. In my case, it looks like:

   tracker_interperter = ‘path_to/anaconda3/envs/xxx_env/bin/python‘;

 

If your tracker depends on some other library that is outside the conda environment, you also need to specify it. In my case, my tracker is dependent on the CUDA library. I need to specify it in tracker_xxx.m file:

   tracker_linkpath = {‘/usr/local/cuda/lib64’};

 

3.     trax tool do not support python3

 

The original trax tool for python in vot-toolkit only supports python2. You need to make some changes to the trax module in the native directory to support python3-based tracker. Fortunately, you only need two steps.

 

First, you need to replace all the ‘xrange’ found in the native trax module files (located at native/trax/python/*.py) with ‘range’.

 

Second, replace line 70, file ‘trax/region.py’ with ‘tokens = list(map(float, string.split(‘.’)))’.

 

http://www.votchallenge.net/howto/integration_channels.html

 

 

Python

上一步的 MATLAB 可以正常运行,说明 TraX 库正常,就可以测试官方提供的 python tracker. 可以直接对上一步workspace 中的文件进行修改,没必要重新创建 workspace (特意选择Python)。

还是修改 workspace 下的 tracker_NCC.m 文件,修改为:

1
2
3
tracker_label = ['NCC'];
tracker_command = generate_python_command('python_ncc',{'/home/ubuntu/VOT/vot-toolkit/tracker/examples/python'});
tracker_interperter = 'python';

将 generate_matlab_command() 修改为 generate_python_command(),参数还是对应 python 版的 tracker 文件名和目录,tracker_interperter其实不用修改,但是给他点面子改成 'python'.

运行 run_test.m 试一试,果然出错了!当我 Anaconda 不存在吗?

  • wrong python interpreter

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    ...
    CLIENT: Creating process /usr/bin/python  -c "import sys; sys.path.append('/home/ubuntu/VOT/vot-toolkit/native/trax/python');sys.path.append('/home/ubuntu/VOT/vot-toolkit/tracker/examples/python'); import python_ncc"
    CLIENT: Working directory is /tmp/tp8b02cd23_8b86_416c_8e82_000ea94a4639
    ...
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/ubuntu/VOT/vot-toolkit/tracker/examples/python/python_ncc.py", line 6, in <module>
        import cv2
    ImportError: No module named cv2
    ...
    

    但是官方并没有说如何选择 python 解释器。谷歌一下,有线索,根据这条线索,修改tracker_interperter

    1
    
    tracker_interpreter = '/home/ubuntu/anaconda2/envs/tf15/bin/python';
    

    还是报同样的错,解释器仍然是/usr/bin/python(早就说 tracker_interpreter 没用了!)。

    也许是版本原因造成这种方法不再适用,但是,观察 generate_python_command.m 文件:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    function command = generate_python_command(script, paths)
    
    trax_python = get_global_variable('trax_python');
    python_exec = get_global_variable('python');
    
    % If path to python trax implementatin is set then we attempt to export it to tracker
    if ~isempty(trax_python)
        paths = cat(1, {trax_python}, paths);
    end
    
    ...
    

    python_exec不就是解释器么,编程规范真是好东西。修改它肯定可以解决问题。在 workspace 下的 configuration.m 文件中添加一句:

    1
    
    set_global_variable('python', '/home/ubuntu/anaconda2/envs/tf15/bin/python');
    

    成功运行。

Conclusion

VOT toolkit 调用 python 版本的 tracker 需要修改 workspace 目录下的两个文件

  1. tracker_NCC.m 中:
    • tracker_command 的函数名和参数
    • tracker_interperter 改为'python'(好像没什么用)
    • 如果 tracker 使用了 CUDA、cuDNN,需要加上tracker_linkpath = {'/usr/local/cuda/lib64','/usr/local/cuda/extras/CUPTI/lib64'}
  2. configuration.m 中:
    • 添加 python 解释器路径:set_global_variable('python', '<interpreter_path>');

由于 Trax 支持了 Python3VOT/trax-master/python/trax 目录下的 python 文件中有以下语句)

1
2
3
4
...
if (sys.version_info > (3, 0)):
    xrange = range
...

所以不必特意将 python demo 中的 xrange 改成 range 。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值