Where exactly is numpy hidden?

4 posts / 0 new
Last post
Paxo Parrot
Where exactly is numpy hidden?

The base formulapi code that was tested seems to work fine, but since it was only the basic code it didn't want to avoid stationary cars.

It was recommended to look at adjusting some of the data in the numpy file.

Can anyone provide me with a location of where the numpy file is specifically please?

I've been told it's part of the python libraries, but since there's several libraries installed, I just don't have a clue where to begin.

I've tried find searches in the file explorer, but it doesn't show up. I can only assume it's a hidden file. :(

Geoff Riley
Geoff Riley's picture

Hi Paxo,

numpy (NumPy) is one of the very common libraries that you will come across with Python: it defines an extra object type of array. In particular it allows you to do (multi-dimensional) array maths.

The library itself is hidden away with all the other general libraries are is not generally for modifying.

cv2 (Computer Vision v2) is a second library that works with arrays. Older versions used to use different array types, but now the two array types are essentially the same. This means that you can do calculations on the arrays using numpy and put the results into cv2.

Caveat: cv2 needs arrays working in integers, numpy can work with floats as well, so it may be necessary to perform a conversion after doing numpy calculations.

All the code that you might want to alter is in ImageProcessor.py, particularly in the function named ProcessImage.

Hint: image is an array to start you off. :)

I hope that helps.


piborg's picture
You probably want to change ImageProcessor.py

As Geoff says above, NumPy is a very standard library for Python used by a lot of programs.
It adds the array data type and a lot of very useful mathematical processing functions.
We would not recommend altering the NumPy code at all.

I think the confusion is probably that we are using NumPy quite a bit in the processing code.
It might be a good idea to take a look at this as a crash-course in using NumPy:

Before changing the code I would suggest you take a look at our blog post: Detecting traffic.
This is more or less a quick example of what the real code does.

The detection code itself is all in ImageProcessor.py.
The parts you are looking for are:

  1. The unknownPointCount value which is used to make the decision.
    This is towards the end of ProcessImage in the StreamProcessor class.
  2. The code which looks at unknownPointCount and decides if it should overtake.
    This is in the if checkForOverrides: section of PerformOverrides in the ControlLoop class.
  3. Finally the last piece that finishes the overtaking
    This is also in PerformOverrides in the ControlLoop class.
Paxo Parrot
Okay, got you now. When I was

Okay, got you now. When I was told to look at numpy, I was looking for a specific file called numpy.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Syntax highlight code surrounded by the <pre class="brush: lang">...</pre> tags, where lang is one of the following language brushes: bash, cpp, perl, python.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Comment Images
Files must be less than 10 MB.
Allowed file types: png gif jpg jpeg.
Comment Attachments
Files must be less than 10 MB.
Allowed file types: txt pdf nfo doc docx rtf jpg png gif bmp zip tar gz csv xls.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.