From the internet I have learnt that Python does not have any standard modules to access the webcam. In order to capture a photo using the WebCam, we need to use an open source module called opencv (cv2 for python) which is written in C++. My question is why does python interpreter not throw an error when a piece of C++ code is used inside a Python code? How can it interpret something which is not python?
-
11. The de facto reference implementation of Python is written in C and is literally called cpython. 2. How do you think Python talks to the operating system written in C/C++? 3. All of this is covered very well elsewhere, e.g. here on this very site, or here, or the official docs, or...Jared Smith– Jared Smith2022-05-24 11:33:38 +00:00Commented May 24, 2022 at 11:33
-
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.Community– Community Bot2022-05-24 12:27:06 +00:00Commented May 24, 2022 at 12:27
Add a comment
|
1 Answer
The python functions act as wrappers, meaning they just provide a python interface but behind the scenes they just execute the C++ code. So all you need is some code that lets you interpret the data that is sent from C++ and find the python equivalent like https://docs.python.org/3/library/ctypes.html and you're done. Though in case of OpenCV people have already done that for you so you can use the python stuff as if it were written in python.