Code Monkey home page Code Monkey logo

tpk4128-industrial-mechatronics's Introduction

TPK4128 Industrial Mechatronics

Introduction to Python programming for the course TPK4128 Industrial Mechatronics at the Department of Mechanical and Industrial Engineering, NTNU, Norwegian University of Science and Technology

Exercise: Building a webcam server using OpenCV and Python

The task is to build a Python module that implements a socket server that fetches images from a webcam and sends it over a TCP/IP or UDP socket when it gets a request from a client.

  1. Install Ubuntu in a virtual machine, e.g., VirtualBox.
  2. Mount the the integrated webcam into the Ubuntu VM.
    1. Make sure the virtual machine is not running and your webcam is not being used.
    2. Bring up the main VBox window and in the details tab for your virtual machine click USB.
    3. Make sure "Enable USB Controller" is selected. Also make sure that "Enable USB 2.0 (EHCI) Controller" is selected too.
    4. Click the "Add filter from device" button (the cable with the '+' icon).
    5. Select your device from the list.
    6. Now click OK and start your VM.
  3. Open a terminal and execute the command ls /dev. You should now see video0 in the output. Note that you might need to add the camera manually from the top menu: Devices > Webcams > NameOfYourCamera
  4. Install the tpk4128 module (with dependencies):
mkdir -p ~/tpk4128_ws/src
cd ~/tpk4128_ws/src
git clone https://github.com/tingelst/tpk4128-industrial-mechatronics.git
pip3 install ./tpk4128-industrial-mechatronics # Use pip for Python 2
  1. Implement the Camera class in the file tpk4128/camera_opencv.py. See https://docs.opencv.org/3.4/dd/d43/tutorial_py_video_display.html for a tutorial on how to open a video stream from a webcam.
  2. Implement the scripts/run_client_opencv.py script, that sends a message over localhost to a server implemented in the scripts/run_server_opencv.py script.
  3. Open a new terminal and execute the run_server_opencv.py script.
  4. Open a new terminal and execute the run_client_opencv.py script. You should now see a live stream from your webcam.
  5. If time permits, work together in pairs and try to get the above system to work between two remote machines.

tpk4128-industrial-mechatronics's People

Contributors

tingelst avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.