The DarkHelp Python
API uses the simplified DarkHelp C API.
- Note
- The Python API does not expose 100% of what is available in the DarkHelp C++ API.
Calls such as DarkHelp.EnableNamesIncludePercentage()
map to the C
API EnableNamesIncludePercentage() which is documented as DarkHelp::Config::names_include_percentage. Using this API, DarkHelp can be used with advanced features such as tiling and snapping.
Example code:
import DarkHelp
dh = DarkHelp.CreateDarkHelpNN("cars.cfg".encode("utf-8"), "cars.names".encode("utf-8"), "cars.weights".encode("utf-8"))
DarkHelp.SetThreshold(dh, 0.35)
DarkHelp.SetAnnotationLineThickness(dh, 1)
DarkHelp.EnableTiles(dh, True)
DarkHelp.EnableCombineTilePredictions(dh, True)
DarkHelp.EnableOnlyCombineSimilarPredictions(dh, False)
DarkHelp.SetTileEdgeFactor(dh, 0.18f)
DarkHelp.SetTileRectFactor(dh, 1.22f)
DarkHelp.PredictFN(dh, "car_01.jpg".encode("utf-8"))
DarkHelp.Annotate(dh, "output.jpg".encode("utf-8"))
json = DarkHelp.GetPredictionResults(dh)
DarkHelp.DestroyDarkHelpNN(dh)
print(json.decode())
See the sample file src-python/example.py
which shows how to use the Python
API.
Convenient links to some of the API call documentation to get started: