Example Code for Python - Object Contour Recognition Based on Computer OpenCV
This example demonstrates how to use OpenCV on a computer to recognize object contours.
Hardware Preparation
Software Preparation
- Python IDLE (https://www.python.org/)
Other Preparation Work
-
Burn the code to the module (use the code from Section 5.3 or 5.4).
-
Install the Python environment (https://www.python.org/). Skip this step if it is already installed.
-
Install the opencv-python library:
-
Press Win+R, enter "cmd" to open the command window.
-
Enter "pip install opencv-python" to install the opencv-python library.
-
-
Open Python IDLE, go to File->Open..., select the Python file (use "openCV_5_3.py" if you are using the example from Section 5.3; use "openCV_5_4.py" if you are using the example from Section 5.4). Press F5 in the new window that appears to see the image.
Sample Code
Result

Additional Information
-
When using "openCV_5_3.py", remember to modify the IP address parameter.
-
When using "openCV_5_4.py", remember to modify the camera_index parameter.
Was this article helpful?
