Posted 4 Days Ago Job ID: 2093037 15 quotes received

OPenCV Expert Needed for robotics

Fixed Price$1k-$2.5k
Quotes (15)  ·  Premium Quotes (0)  ·  Invited (0)  ·  Hired (1)

  Send before: September 25, 2024

Send a Quote

Programming & Development Programming & Software

I need a someone expert in OpenCV for a robotics job. Tasks . You have to do the opencv code in python. 

1. we are making a robotics vehicle . there will be a camera attached with it and the camera has to detect the color and distance of the object from the vehicle using opencv. then it has to steer the servo according to that to turn left / right and dodge the obstacle. 

1. Video Stream Capture (vStream class)

  • The vStream class handles video input from a camera. It initializes a camera feed and starts a background thread to continuously update the captured frames.
  • The update method continuously reads frames from the camera, resizes them, and calculates the frames per second (FPS).
  • The getFrame method returns the most recent frame captured by the camera.

2. Utility Functions

  • clamp: Limits a value to a specified range.
  • mapF and mapFC: Maps a value from one range to another, with mapFC also clamping the result within the target range.
  • lerpF: Linearly interpolates between two values.

3. Camera and Serial Setup

  • The code initializes a camera feed using vStream and sets up a serial connection to communicate with a microcontroller (likely an Arduino or similar).
  • It attempts to connect to a serial device (/dev/ttyUSB0) at 115200 baud. If successful, it prints a confirmation message.

4. Loading Color Thresholds (loadVal)

  • The loadVal function loads color ranges and other parameters (such as blur values) from a JSON file (colors.json), which is essential for detecting specific colors in the video feed.

5. Line Detection (getLines and showLines)

  • getLines: Identifies lines in the video feed by applying color masks based on the provided color ranges (e.g., blue, orange). It detects contours and filters them based on size and orientation.
  • showLines: Draws the detected lines on the video frame, color-coding them for visualization.

6. Object Detection (makeMask, getObjs)

  • makeMask: Creates a mask for a specific color range and finds contours within that mask.
  • getObjs: Identifies objects of a specific color, calculates their position and distance, and returns a list of detected objects. It also draws bounding boxes around these objects on the frame.

7. Serial Communication (serialComm)

  • This function handles serial communication with the microcontroller. It reads data from the serial port, decodes it, and updates variables like trackDir, turnCount, and gotLine.
  • It sends commands to the microcontroller, such as object type, position, and distance, to control the vehicle's movements.

8. Line Detection and Navigation Logic (linesD)

  • The linesD function continuously processes the video feed to detect lines of specific colors (blue or orange) and decides the vehicle’s navigation path.
  • It determines the first line to follow (firstLine), tracks the number of turns (turnCount), and handles situations where the vehicle might lose the line or detect it again.

9. Main Loop

  • The main loop captures frames, applies Gaussian blur, and converts the image to the HSV color space for color-based processing.
  • It detects green and red objects using the makeMask and getObjs functions, and sorts these objects based on distance to decide which one to respond to.
  • It updates the display with FPS, turn count, and detected objects, and shows the processed video frames.

10. Multithreading

  • commThread: Manages the serial communication in a separate thread.
  • linesThread: Runs the line detection and navigation logic in another thread.

11. Vehicle Control

  • Based on the detected objects and lines, the vehicle decides whether to move left or right, depending on whether it sees a red or green object, and also tracks lines to navigate through a predefined path.


    This is a one time job. we will proovide you the details of the bots mechanics and you can complete the code in your own preferances. 
... Show more
Hughes M United States