Tag Archives: Python

Python 3D Graphics LESSON 3: Parameterizing your 3D Model

In this lesson we show you the importance of building a parameterized model for your 3D graphics in Python using Visual Python. You can manage large scenes unless you are doing it with parameterized dimensions. The video above takes you through it step by step. Here is the code for the parameterized box and marble we developed in Lesson 3:

 

Launch a Windows WEB Camera in Ten Lines of Code with OpenCV

In this lesson we show you step-by-step how to launch a WEB camera using OpenCV running on windows. In the video we show how to install OpenCV and how to write your first simple programs. Below is the code we developed in the video to launch the WEB cam.

 

Jetson Xavier NX Lesson 12: Intelligent Scanning for Objects of Interest

In this Video Tutorial we show how a camera on a pan/tilt control system can be programmed to search for an object of interest, and then track it when found.  Our system has two independent camera systems, and each can track a separate item of interest independently. The code is written in python, using the OpenCV library. The video takes you through the lesson step-by-step, and then the code is included below for your convenience.

If you want to play along at home, we are using the Jetson Xavier NX, which you can pick up HERE. You will also need to of the bracket/servo kits, which you can get HERE, and then two Raspberry Pi Version two cameras, available HERE.

 

9-Axis IMU LESSON 12: Passing Data From Arduino to Python

In this lesson we show how to pass data from Arduino to Python using a Com Port. This is important for our 9-Axis IMU project as we want to take advantage of the processing power and 3D graphics capabilities of Python. Our goal is to get the date from Arduino to Python, and then create a dynamic 3D visualization of our system. The first step in this goal is to pass the data from arduino to Python.

In order to do this, a first step is to install the pyserial library. If you followed our python installation tutorial in lesson 11, then it is easy to install pyserial by just opening a windows command prompt, and then typing:

pip install pyserial

If this does not work, likely you did not install python according to the instruction in lesson 11.

In order to show a simple demonstration of passing data, we can use the following code on the arduino side, which just generates x, y, and z numbers and passes them to Python.

We can grab these numbers from the Com port on the Python side with the following code. Note that you should use the com port your arduino is on, which likely will not be the same as mine (which was ‘com5’).

The above example is just a simple method for passing different channels from Arduino to Python.

 

For our IMU project, we want to use the code we left off with Lesson 10. However, note we can scale back on the number of data channels, because we just want the calibration data and then the final roll, pitch and yaw numbers. This is the arduino code that will pass those parameters.

Then, on the Python side we can grab and parse the data with this code.

In the next lesson we will install Vpython and begin building our code to create dynamic 3D visualizations of our system.