-2

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?

2
  • 1
    1. 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... Commented 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. Commented May 24, 2022 at 12:27

1 Answer 1

-1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.