How to use e-con Systems’ USB cameras with MATLAB

MATLAB is a high-level language and interactive environment developed by MathWorks, used for numerical computation, visualization, and programming. It allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages.

MATLAB provides extensive image processing and computer vision toolboxes that are instrumental in developing and testing algorithms for object detection, feature extraction, image classification, and more. These algorithms form the backbone of embedded vision systems that enable devices to interpret visual information from their surroundings.

With MATLAB, developers can also simulate and prototype vision algorithms quickly before deploying them on hardware. This is crucial for applications that demand real-time processing like autonomous vehicles and surveillance systems.

The blog provides a comprehensive guide on interfacing e-con Systems’ USB cameras with MATLAB, covering both online and offline usage scenarios.

Interfacing USB cameras with MATLAB

  • Real-time data acquisition: MATLAB can directly acquire images and video streams from USB cameras, enabling real-time analysis and processing.
  • Rapid prototyping: Developers can quickly prototype and test their image processing and computer vision algorithms with live data, accelerating the development process.
  • Flexible development: MATLAB provides a user-friendly and flexible development environment, equipped with extensive libraries and toolboxes for image processing and computer vision.
  • Cross-platform compatibility: MATLAB’s support for USB cameras is cross-platform, meaning developers can work on Windows, macOS, and Linux.

Using e-con Systems’ USB Cameras with MATLAB

e-con Systems’ USB 3.0 Cameras are UVC compliant and act as plug-and-play imaging solutions that can be easily used along with MATLAB without any hassle.

Let’s now look at the steps required to work with MATLAB:

Please note that you can create and use a free trial for 30 days using this link: https://in.mathworks.com/campaigns/products/trials.html

After you create an account and register, you will be directed to https://matlab.mathworks.com, where you can use MATLAB online or offline.

Let’s explore both options.

First, let’s look at how to use USB cameras with MATLAB online

  1. Click Open MATLAB Online and open Live Script from the new menu on the top-right corner.
  1. Connect the camera to the PC and enter webcamlist in the Command Window to list the number of cameras connected to the PC.
  1. Use the camera node number you want to access or the name of the camera.
  1. Enter the following sample code and run the code to view the streaming of the camera:

cam=webcam('See3CAM_CU135'); or cam=webcam(1)
preview(cam);

 

  1. Enter the following sample code to take an image from the camera stream:

cam=webcam('See3CAM_CU135');
preview(cam);
img=snapshot(cam)
imshow(img);
clear();

Now, we can view the output from the USB camera.

Next, let’s look at using the offline MATLAB application (similar to online)

  1. Click install MATLAB from https://matlab.mathworks.com (we have tested it for the R2023B version).
  1. Install the additional package MATLAB Support Package for USB Webcams.

  1. Run the same code used previously without any changes to get the stream and images in the desktop application.

Then, a few support packages must be installed with MATLAB to work with cameras. Hence, follow the steps in the below link to install the necessary support packages Like Windows Video, DCAM and others, if needed.

https://in.mathworks.com/help/imaq/image-acquisition-support-packages-for-hardware-adaptors.html

Accessing Cameras through Image Acquisition Explorer APP

MATLAB also provides an application for image acquisition, which you can easily use to work with cameras. It can be found in the Apps tab of the MATLAB desktop application.

Here’s how you can access it:

  1. Open the Image Acquisition application and select the camera you want to stream (this will open a window with camera functions and tools to operate).

  1. In the Device Properties Tab, adjust the camera’s UVC controls like brightness, contrast, and more. The ROI position allows you to choose ROI for streaming the camera
  1. At the top of the screen, select format and color space. There are also image capture and video recording options. You can modify the path for saving the images or video by selecting the file option.
  1. Please select greyscale as the color space for monochrome cameras.

Accessing USB Cameras through MATLAB Simulink

  1. Open Simulink from the MATLAB tool and select new blank model.

  1. Navigate to the Modelling tab and select library browser from the Component
  1. Drag and drop the Image Acquisition Toolbox from the menu and double click it to select the camera and other functions like output format.
  1. Adjust the necessary settings and click create to create an image acquisition block.
  1. Search video display in the search box, which will be available in the sink section of the computer vision toolbox.
  1. Connect both components and click Run from Modelling section to execute the blocks.

Leveraging e-con Systems’ Monochrome Cameras with MATLAB

e-con Systems’ monochrome cameras require additional filters to be installed to ensure compatibility with MATLAB. Therefore, it’s necessary to install e-CAMView, our Windows camera application, which provides the required filters for your PC. This step is mandatory for using our monochrome cameras.

Download e-CAMView here: https://www.e-consystems.com/e-CAMView-Windows-camera-streaming-app.asp#Download

Our monochrome cameras are compatible with applications in MATLAB. However, they are not compatible with code-based usage due to the output format.

Here’s a list of cameras that have been tested and are compatible with the image acquisition application.

See3CAM_160

See3CAM_CU135

See3CAM_CU135M

See3CAM_130

See3CAM_CU130

FSCAM_CU135

See3CAM_CU55

See3CAM_30

See3CAM_CU30

See3CAM_CU20

See3CAM_24CUG

See3CAM_27CUG

ToF Camera – DepthVista

See3CAM_50CUG

e-CAM22_USB

e-CAM51B_USB

See3CAM_CU81

See3CAM_CU38

See3CAM_CU27

See3CAM_CU22

Tara

You can find more learning resources here:

https://matlabacademy.mathworks.com/?s_tid=mlh_sn_mlac#getting-started

https://in.mathworks.com/products/image-acquisition.html

Browse our Camera Selector page to explore our full product portfolio.

If you are looking for more information about using USB cameras with MATLAB, please write to us at camerasolutions@e-consystems.com.

Related posts

e-con Systems Launches See3CAM_CU83 – A 4K RGB-IR USB Camera Delivering Stunning Visuals Day and Night

e-con Systems Offers a Patented Hot-Pluggable GMSL Camera System for Uninterrupted Host Processor Streaming

e-con Systems Introduces STURDeCAM34: The World’s First 140dB HDR Hot Pluggable GMSL2 Camera Targeting Automotive Applications