最近在编译的Hoiem的一个项目, 就是Recovering Occlusion Boundaries。 不得不说, 这家伙是在是太不friendly了,不放源代码,只放编译好的mex文件。而 他放的代码都是0607年的, 那时候matlab版本很低。而且gcc也只有可怜的3.3,现在都4.8了! 所以用他的代码, 会让你无比纠结。
不过还是调试成功了。 但在调试时遇到一个很有意思的问题: mex编译c文件报错。
c文件如下, treevalc.c
#include "mex.h"
#include <stdlib.h>
#include <stdio.h>
/**
* Return the decision tree node corresponding to the given value set
*
* var[n]: the attribute ids for node n
* cut[n]: the threshold value for node n
* left_child[n]: the node id of the left child of node n, 0 if node n is terminal
* right_child[n]: the node id of the right child of node n, 0 if node n is terminal
* ncatsplit[c]: the number of values resulting in a left branch
* catsplit[c]: the values that would result in a left branch
* attributes: the attribute (variable) values for each feature
**/
void
treevalc(int* var, double* cut, int* left_child, int* right_child,
int* ncatsplit, double** catsplit,
double* attributes,
int* node_id) {
int currnode = 0;
int nextnode;
int currvar;
double currval;
int cid, v;
int numvals;
double* vals;
/* printf("init nodes: %d %d \n", left_child[currnode], right_child[currnode]); */
/* until reached terminal node */
while ((left_child[currnode] != 0) && (right_child[currnode] != 0)) {
/*printf("currnode: %d\n", currnode);*/
nextnode = -1;
currvar = abs(var[currnode])-1;
currval = attributes[currvar];
/* decision based on thresholded float value */
if (var[cu