VideoPopulation
VideoPopulation(self,
geometry,='4',
opencv_version=None,
name=False,
copied=0,
net_id )
Rate-coded Population allowing to feed a webcam input into the firing rate of a population (each neuron represents one pixel).
This extension requires the C++ library OpenCV >= 4.0 (apt-get/yum install opencv). pkg-config opencv4 --cflags --libs
should not return an error. vtk
might additionally have to be installed.
The extensions has to be explicitly imported:
import ANNarchy as ann
from ANNarchy.extensions.image import VideoPopulation
= ann.Network()
net = net.create(VideoPopulation(geometry=(480, 640)))
pop
compile()
net.
0)
pop.start_camera(
while(True):
pop.grab_image()10.0) net.simulate(
About the geometry:
- If the geometry is 2D, it corresponds to the (height, width) of the image. Only the luminance of the pixels will be represented (grayscale image).
- If the geometry is 3D, the third dimension can be either 1 (grayscale) or 3 (color).
If the third dimension is 3, each will correspond to the RGB values of the pixels.
Warning: due to the indexing system of Numpy, a 640*480 image should be fed into a (480, 640) or (480, 640, 3) population.
Parameters
Name | Type | Description | Default |
---|---|---|---|
geometry | tuple | population geometry as tuple. It must be fixed through the whole simulation. If the camera provides images of a different size, it will be resized. | required |
opencv_version | str | OpenCV version (default=4). | '4' |
name | str | unique name of the population (optional). | None |
Methods
Name | Description |
---|---|
start_camera | Starts the webcam with the corresponding device (default = 0). |
grab_image | Grabs one image from the camera and feeds it into the population. |
release | Releases the camera: |
start_camera
=0) start_camera(camera_port
Starts the webcam with the corresponding device (default = 0).
On linux, the camera port corresponds to the number in /dev/video0
, /dev/video1
, etc.
grab_image
grab_image()
Grabs one image from the camera and feeds it into the population.
The camera must be first started with:
0) pop.start_camera(
release
release()
Releases the camera:
pop.release()