Reputation: 63
i wrote the C code as follow:
int main(int argc, char** argv)
{
PyObject *mod, *name, *func;
Py_Initialize();
mod = PyImport_ImportModule("perf_tester");
if(!mod)
{
printf("cannot find perf_tester.py");
getchar();
return -1;
}
name = PyObject_GetAttrString(mod, "CheckSharpness");
if(!name)
{
printf("can not find CheckSharpness");
getchar();
return -1;
}
func = PyObject_GetAttrString(name,"F");
if(!func)
{
printf("can not find function");
getchar();
return -1;
}
Py_Finalize();
system("pause");
return 0;
}
except for func, i could find mod and name.
and the partial of the perf_tester.py as follow:
def CheckSharpness(sample, edges, min_pass_mtf, min_pass_lowest_mtf,
use_50p, mtf_sample_count, mtf_patch_width,
mtf_crop_ratio=_MTF_DEFAULT_CROP_RATIO,
n_thread=1):
mtfs = [mtf_calculator.Compute(sample, line_start[t], line_end[t],
mtf_patch_width, mtf_crop_ratio,
use_50p)[0] for t in perm]
F = open("data.txt","w")
F.write(str(mtfs))
F.close()
what could I do?
Upvotes: 1
Views: 86
Reputation: 171197
F
is a local variable, it's not a member of CheckSharpness
. It does not exist when CheckSharpness
is not currently running, and each invocation of CheckSharpness
has its own copy. There's no way to access this from outside.
Upvotes: 1