This python_binding project enables Softcam library to be used from Python scripts.
Your python code will look like this:
import softcam
cam = softcam.camera(320, 240, 60)
while True:
img = draw_something()
cam.send_frame(img)
- Build Softcam library according to README.md. You get
softcam.dllin thedistdirectory at the root of this repository. - Run
DownloadPybind11.bat. This batch downloads Pybind11 archive and expands it to be used in the following build of binding. - In a Command Prompt session, activate your target Python environment.
- Run
LaunchVisualStudio.batin the environment. This batch prepares environment variables that point the directory of the Python environment and launch Visual Studio for the solution filepythin_binding.slnwith that environment variables. - On the Visual Studio, build solution with
Release|x64configuration. You will getsoftcam.pydin thex64/Releasedirectory.
Then you can run simple_usage.py. Note that this script requires Numpy and OpenCV installed in your Python environment.
Bring softcam.pyd and softcam.dll together to anywhere you want to use Softcam in python scripts.
Note:
- The color component order should be BGR, not RGB.
- Different version of Python interpreter needs different build of
softcam.pyd.- For example, if you have built
softcam.pydwith Python 3.9, trying to use it on Python 3.8 will fail withImportError.
- For example, if you have built
- You can not change the filename of
softcam.pydafter build.- If you rename it to
foo.pydand runimport fooorimport softcamin your Python code, either will fail with theImportError. - This is because the name of the module is embedded in the file in build time.
- If you rename it to