Example #1
0
static PyObject* create_module (void) {

  //makes sure that PyBobIpFlandmark_Type has a dictionary on tp_dict
  PyBobIpFlandmark_Type.tp_dict = PyDict_New();
  if (!PyBobIpFlandmark_Type.tp_dict) return 0;

  PyBobIpFlandmark_Type.tp_new = PyType_GenericNew;
  if (PyType_Ready(&PyBobIpFlandmark_Type) < 0) return 0;

# if PY_VERSION_HEX >= 0x03000000
  PyObject* module = PyModule_Create(&module_definition);
  auto module_ = make_xsafe(module);
  const char* ret = "O";
# else
  PyObject* module = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr);
  const char* ret = "N";
# endif
  if (!module) return 0;

  /* register the types to python */
  Py_INCREF(&PyBobIpFlandmark_Type);
  if (PyModule_AddObject(module, "Flandmark", (PyObject *)&PyBobIpFlandmark_Type) < 0) return 0;

  /* imports dependencies */
  if (import_bob_blitz() < 0) return 0;
  if (import_bob_core_logging() < 0) return 0;
  if (import_bob_io_base() < 0) return 0;

  return Py_BuildValue(ret, module);
}
Example #2
0
static PyObject* create_module (void) {

# if PY_VERSION_HEX >= 0x03000000
  PyObject* module = PyModule_Create(&module_definition);
  auto module_ = make_xsafe(module);
  const char* ret = "O";
# else
  PyObject* module = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr);
  const char* ret = "N";
# endif
  if (!module) return 0;

  /* imports dependencies */
  if (import_bob_blitz() < 0) return 0;
  if (import_bob_core_logging() < 0) return 0;
  if (import_bob_io_base() < 0) return 0;

  return Py_BuildValue(ret, module);
}
Example #3
0
static PyObject* create_module (void) {

# if PY_VERSION_HEX >= 0x03000000
  PyObject* module = PyModule_Create(&module_definition);
  auto module_ = make_xsafe(module);
  const char* ret = "O";
# else
  PyObject* module = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr);
  const char* ret = "N";
# endif
  if (!module) return 0;

  if (PyModule_AddStringConstant(module, "__version__", BOB_EXT_MODULE_VERSION) < 0) return 0;
  if (!init_BobIpBaseGeomNorm(module)) return 0;
  if (!init_BobIpBaseFaceEyesNorm(module)) return 0;
  if (!init_BobIpBaseLBP(module)) return 0;
  if (!init_BobIpBaseLBPTop(module)) return 0;
  if (!init_BobIpBaseDCTFeatures(module)) return 0;
  if (!init_BobIpBaseTanTriggs(module)) return 0;
  if (!init_BobIpBaseGaussian(module)) return 0;
  if (!init_BobIpBaseMultiscaleRetinex(module)) return 0;
  if (!init_BobIpBaseWeightedGaussian(module)) return 0;
  if (!init_BobIpBaseSelfQuotientImage(module)) return 0;
  if (!init_BobIpBaseGaussianScaleSpace(module)) return 0;
  if (!init_BobIpBaseSIFT(module)) return 0;
  if (!init_BobIpBaseHOG(module)) return 0;
  if (!init_BobIpBaseGLCM(module)) return 0;
  if (!init_BobIpBaseWiener(module)) return 0;

#if HAVE_VLFEAT
  if (!init_BobIpBaseVLFEAT(module)) return 0;
#endif // HAVE_VLFEAT


  static void* PyBobIpBase_API[PyBobIpBase_API_pointers];

  /* exhaustive list of C APIs */

  /**************
   * Versioning *
   **************/

  PyBobIpBase_API[PyBobIpBase_APIVersion_NUM] = (void *)&PyBobIpBase_APIVersion;

  /********************************
   * Bindings for bob.ip.base.LBP *
   ********************************/

  PyBobIpBase_API[PyBobIpBaseLBP_Type_NUM] = (void *)&PyBobIpBaseLBP_Type;
  PyBobIpBase_API[PyBobIpBaseLBP_Check_NUM] = (void *)&PyBobIpBaseLBP_Check;
  PyBobIpBase_API[PyBobIpBaseLBP_Converter_NUM] = (void *)&PyBobIpBaseLBP_Converter;

#if PY_VERSION_HEX >= 0x02070000

  /* defines the PyCapsule */

  PyObject* c_api_object = PyCapsule_New((void *)PyBobIpBase_API,
      BOB_EXT_MODULE_PREFIX "." BOB_EXT_MODULE_NAME "._C_API", 0);

#else

  PyObject* c_api_object = PyCObject_FromVoidPtr((void *)PyBobIpBase_API, 0);

#endif

  if (!c_api_object) return 0;

  if (PyModule_AddObject(module, "_C_API", c_api_object) < 0) return 0;


  /* imports bob.ip.base's C-API dependencies */
  if (import_bob_blitz() < 0) return 0;
  if (import_bob_core_random() < 0) return 0;
  if (import_bob_core_logging() < 0) return 0;
  if (import_bob_io_base() < 0) return 0;
  if (import_bob_sp() < 0) return 0;

  return Py_BuildValue(ret, module);
}
Example #4
0
static PyObject* create_module (void) {

  PyBobLearnActivation_Type.tp_new = PyType_GenericNew;
  if (PyType_Ready(&PyBobLearnActivation_Type) < 0) return 0;

  PyBobLearnIdentityActivation_Type.tp_base = &PyBobLearnActivation_Type;
  if (PyType_Ready(&PyBobLearnIdentityActivation_Type) < 0) return 0;

  PyBobLearnLinearActivation_Type.tp_base = &PyBobLearnActivation_Type;
  if (PyType_Ready(&PyBobLearnLinearActivation_Type) < 0) return 0;

  PyBobLearnLogisticActivation_Type.tp_base = &PyBobLearnActivation_Type;
  if (PyType_Ready(&PyBobLearnLogisticActivation_Type) < 0) return 0;

  PyBobLearnHyperbolicTangentActivation_Type.tp_base =
    &PyBobLearnActivation_Type;
  if (PyType_Ready(&PyBobLearnHyperbolicTangentActivation_Type) < 0) return 0;

  PyBobLearnMultipliedHyperbolicTangentActivation_Type.tp_base =
    &PyBobLearnActivation_Type;
  if (PyType_Ready(&PyBobLearnMultipliedHyperbolicTangentActivation_Type) < 0)
    return 0;

# if PY_VERSION_HEX >= 0x03000000
  PyObject* module = PyModule_Create(&module_definition);
  auto module_ = make_xsafe(module);
  const char* ret = "O";
# else
  PyObject* module = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr);
  const char* ret = "N";
# endif
  if (!module) return 0;

  /* register the types to python */
  Py_INCREF(&PyBobLearnActivation_Type);
  if (PyModule_AddObject(module, "Activation", (PyObject *)&PyBobLearnActivation_Type) < 0) return 0;

  Py_INCREF(&PyBobLearnIdentityActivation_Type);
  if (PyModule_AddObject(module, "Identity", (PyObject *)&PyBobLearnIdentityActivation_Type) < 0) return 0;

  Py_INCREF(&PyBobLearnLinearActivation_Type);
  if (PyModule_AddObject(module, "Linear", (PyObject *)&PyBobLearnLinearActivation_Type) < 0) return 0;

  Py_INCREF(&PyBobLearnLogisticActivation_Type);
  if (PyModule_AddObject(module, "Logistic", (PyObject *)&PyBobLearnLogisticActivation_Type) < 0) return 0;

  Py_INCREF(&PyBobLearnHyperbolicTangentActivation_Type);
  if (PyModule_AddObject(module, "HyperbolicTangent", (PyObject *)&PyBobLearnHyperbolicTangentActivation_Type) < 0) return 0;

  Py_INCREF(&PyBobLearnMultipliedHyperbolicTangentActivation_Type);
  if (PyModule_AddObject(module, "MultipliedHyperbolicTangent", (PyObject *)&PyBobLearnMultipliedHyperbolicTangentActivation_Type) < 0) return 0;

  static void* PyBobLearnActivation_API[PyBobLearnActivation_API_pointers];

  /* exhaustive list of C APIs */

  /**************
   * Versioning *
   **************/

  PyBobLearnActivation_API[PyBobLearnActivation_APIVersion_NUM] = (void *)&PyBobLearnActivation_APIVersion;

  /*************************************************
   * Bindings for bob.learn.activation.Activation *
   *************************************************/

  PyBobLearnActivation_API[PyBobLearnActivation_Type_NUM] = (void *)&PyBobLearnActivation_Type;

  PyBobLearnActivation_API[PyBobLearnActivation_Check_NUM] = (void *)&PyBobLearnActivation_Check;

  PyBobLearnActivation_API[PyBobLearnActivation_NewFromActivation_NUM] = (void *)&PyBobLearnActivation_NewFromActivation;

  /***********************************************
   * Bindings for bob.learn.activation.Identity *
   ***********************************************/

  PyBobLearnActivation_API[PyBobLearnIdentityActivation_Type_NUM] = (void *)&PyBobLearnIdentityActivation_Type;

  /*********************************************
   * Bindings for bob.learn.activation.Linear *
   *********************************************/

  PyBobLearnActivation_API[PyBobLearnLinearActivation_Type_NUM] = (void *)&PyBobLearnLinearActivation_Type;

  /***********************************************
   * Bindings for bob.learn.activation.Logistic *
   ***********************************************/

  PyBobLearnActivation_API[PyBobLearnLogisticActivation_Type_NUM] = (void *)&PyBobLearnLogisticActivation_Type;

  /********************************************************
   * Bindings for bob.learn.activation.HyperbolicTangent *
   ********************************************************/

  PyBobLearnActivation_API[PyBobLearnHyperbolicTangentActivation_Type_NUM] = (void *)&PyBobLearnHyperbolicTangentActivation_Type;

  /******************************************************************
   * Bindings for bob.learn.activation.MultipliedHyperbolicTangent *
   ******************************************************************/

  PyBobLearnActivation_API[PyBobLearnMultipliedHyperbolicTangentActivation_Type_NUM] = (void *)&PyBobLearnMultipliedHyperbolicTangentActivation_Type;

#if PY_VERSION_HEX >= 0x02070000

  /* defines the PyCapsule */

  PyObject* c_api_object = PyCapsule_New((void *)PyBobLearnActivation_API,
      BOB_EXT_MODULE_PREFIX "." BOB_EXT_MODULE_NAME "._C_API", 0);

#else

  PyObject* c_api_object = PyCObject_FromVoidPtr((void *)PyBobLearnActivation_API, 0);

#endif

  if (c_api_object) PyModule_AddObject(module, "_C_API", c_api_object);

  /* imports dependencies */
  if (import_bob_blitz() < 0) return 0;
  if (import_bob_core_logging() < 0) return 0;
  if (import_bob_io_base() < 0) return 0;

  return Py_BuildValue(ret, module);
}
static PyObject* create_module (void) {

  PyBobLearnLinearMachine_Type.tp_new = PyType_GenericNew;
  if (PyType_Ready(&PyBobLearnLinearMachine_Type) < 0) return 0;

  PyBobLearnLinearPCATrainer_Type.tp_new = PyType_GenericNew;
  if (PyType_Ready(&PyBobLearnLinearPCATrainer_Type) < 0) return 0;

  PyBobLearnLinearFisherLDATrainer_Type.tp_new = PyType_GenericNew;
  if (PyType_Ready(&PyBobLearnLinearFisherLDATrainer_Type) < 0) return 0;

  PyBobLearnLinearCGLogRegTrainer_Type.tp_new = PyType_GenericNew;
  if (PyType_Ready(&PyBobLearnLinearCGLogRegTrainer_Type) < 0) return 0;

  PyBobLearnLinearWhiteningTrainer_Type.tp_new = PyType_GenericNew;
  if (PyType_Ready(&PyBobLearnLinearWhiteningTrainer_Type) < 0) return 0;

  PyBobLearnLinearWCCNTrainer_Type.tp_new = PyType_GenericNew;
  if (PyType_Ready(&PyBobLearnLinearWCCNTrainer_Type) < 0) return 0;

# if PY_VERSION_HEX >= 0x03000000
  PyObject* m = PyModule_Create(&module_definition);
# else
  PyObject* m = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr);
# endif
  if (!m) return 0;
  auto m_ = make_safe(m);

  /* register the types to python */
  Py_INCREF(&PyBobLearnLinearMachine_Type);
  if (PyModule_AddObject(m, "Machine", (PyObject *)&PyBobLearnLinearMachine_Type) < 0) return 0;

  Py_INCREF(&PyBobLearnLinearPCATrainer_Type);
  if (PyModule_AddObject(m, "PCATrainer", (PyObject *)&PyBobLearnLinearPCATrainer_Type) < 0) return 0;

  Py_INCREF(&PyBobLearnLinearFisherLDATrainer_Type);
  if (PyModule_AddObject(m, "FisherLDATrainer", (PyObject *)&PyBobLearnLinearFisherLDATrainer_Type) < 0) return 0;

  Py_INCREF(&PyBobLearnLinearCGLogRegTrainer_Type);
  if (PyModule_AddObject(m, "CGLogRegTrainer", (PyObject *)&PyBobLearnLinearCGLogRegTrainer_Type) < 0) return 0;

  Py_INCREF(&PyBobLearnLinearWhiteningTrainer_Type);
  if (PyModule_AddObject(m, "WhiteningTrainer", (PyObject *)&PyBobLearnLinearWhiteningTrainer_Type) < 0) return 0;

  Py_INCREF(&PyBobLearnLinearWCCNTrainer_Type);
  if (PyModule_AddObject(m, "WCCNTrainer", (PyObject *)&PyBobLearnLinearWCCNTrainer_Type) < 0) return 0;

  if (!init_BobLearnLinearBIC(m)) return 0;

  static void* PyBobLearnLinear_API[PyBobLearnLinear_API_pointers];

  /* exhaustive list of C APIs */

  /**************
   * Versioning *
   **************/

  PyBobLearnLinear_API[PyBobLearnLinear_APIVersion_NUM] = (void *)&PyBobLearnLinear_APIVersion;

  /******************************************
   * Bindings for bob.learn.linear.Machine *
   ******************************************/

  PyBobLearnLinear_API[PyBobLearnLinearMachine_Type_NUM] = (void *)&PyBobLearnLinearMachine_Type;

  PyBobLearnLinear_API[PyBobLearnLinearMachine_Check_NUM] = (void *)&PyBobLearnLinearMachine_Check;

  PyBobLearnLinear_API[PyBobLearnLinearMachine_NewFromSize_NUM] = (void *)&PyBobLearnLinearMachine_NewFromSize;

  /*********************************************
   * Bindings for bob.learn.linear.PCATrainer *
   *********************************************/

  PyBobLearnLinear_API[PyBobLearnLinearPCATrainer_Type_NUM] = (void *)&PyBobLearnLinearPCATrainer_Type;

  PyBobLearnLinear_API[PyBobLearnLinearPCATrainer_Check_NUM] = (void *)&PyBobLearnLinearPCATrainer_Check;

  /***************************************************
   * Bindings for bob.learn.linear.FisherLDATrainer *
   ***************************************************/

  PyBobLearnLinear_API[PyBobLearnLinearFisherLDATrainer_Type_NUM] = (void *)&PyBobLearnLinearFisherLDATrainer_Type;

  PyBobLearnLinear_API[PyBobLearnLinearFisherLDATrainer_Check_NUM] = (void *)&PyBobLearnLinearFisherLDATrainer_Check;

  /**************************************************
   * Bindings for bob.learn.linear.CGLogRegTrainer *
   **************************************************/

  PyBobLearnLinear_API[PyBobLearnLinearCGLogRegTrainer_Type_NUM] = (void *)&PyBobLearnLinearCGLogRegTrainer_Type;

  PyBobLearnLinear_API[PyBobLearnLinearCGLogRegTrainer_Check_NUM] = (void *)&PyBobLearnLinearCGLogRegTrainer_Check;

  /***************************************************
   * Bindings for bob.learn.linear.WhiteningTrainer *
   ***************************************************/

  PyBobLearnLinear_API[PyBobLearnLinearWhiteningTrainer_Type_NUM] = (void *)&PyBobLearnLinearWhiteningTrainer_Type;

  PyBobLearnLinear_API[PyBobLearnLinearWhiteningTrainer_Check_NUM] = (void *)&PyBobLearnLinearWhiteningTrainer_Check;

  /***************************************************
   * Bindings for bob.learn.linear.WCCNTrainer *
   ***************************************************/

  PyBobLearnLinear_API[PyBobLearnLinearWCCNTrainer_Type_NUM] = (void *)&PyBobLearnLinearWCCNTrainer_Type;

  PyBobLearnLinear_API[PyBobLearnLinearWCCNTrainer_Check_NUM] = (void *)&PyBobLearnLinearWCCNTrainer_Check;

#if PY_VERSION_HEX >= 0x02070000

  /* defines the PyCapsule */

  PyObject* c_api_object = PyCapsule_New((void *)PyBobLearnLinear_API,
      BOB_EXT_MODULE_PREFIX "." BOB_EXT_MODULE_NAME "._C_API", 0);

#else

  PyObject* c_api_object = PyCObject_FromVoidPtr((void *)PyBobLearnLinear_API, 0);

#endif

  if (c_api_object) PyModule_AddObject(m, "_C_API", c_api_object);

  /* imports dependencies */
  if (import_bob_blitz() < 0) return 0;
  if (import_bob_core_logging() < 0) return 0;
  if (import_bob_io_base() < 0) return 0;
  if (import_bob_learn_activation() < 0) return 0;

  return Py_BuildValue("O", m);
}