ANNarchy 4.8.2
  • ANNarchy
  • Installation
  • Tutorial
  • Manual
  • Notebooks
  • Reference

  • Reference
  • Core components
    • Population
    • Projection
    • Neuron
    • Synapse
    • Monitor
    • PopulationView
    • Dendrite
    • Network
  • Configuration
    • setup
    • compile
    • clear
    • reset
    • set_seed
    • get_population
    • get_projection
    • populations
    • projections
    • monitors
  • Simulation
    • simulate
    • simulate_until
    • step
    • parallel_run
    • enable_learning
    • disable_learning
    • get_time
    • set_time
    • get_current_step
    • set_current_step
    • dt
  • Neuron models
    • LeakyIntegrator
    • Izhikevich
    • IF_curr_exp
    • IF_cond_exp
    • IF_curr_alpha
    • IF_cond_alpha
    • HH_cond_exp
    • EIF_cond_alpha_isfa_ista
    • EIF_cond_exp_isfa_ista
  • Synapse models
    • STP
    • STDP
    • Hebb
    • Oja
    • IBCM
  • Inputs
    • InputArray
    • TimedArray
    • PoissonPopulation
    • TimedPoissonPopulation
    • SpikeSourceArray
    • HomogeneousCorrelatedSpikeTrains
    • CurrentInjection
    • DecodingProjection
    • ImagePopulation
    • VideoPopulation
  • IO
    • save
    • load
    • save_parameters
    • load_parameters
  • Utilities
    • report
  • Random Distributions
    • Uniform
    • DiscreteUniform
    • Normal
    • LogNormal
    • Exponential
    • Gamma
    • Binomial
  • Functions and Constants
    • add_function
    • functions
    • Constant
    • get_constant
  • Plotting
    • raster_plot
    • histogram
    • inter_spike_interval
    • coefficient_of_variation
    • population_rate
    • smoothed_rate
  • Callbacks
    • every
    • callbacks_enabled
    • disable_callbacks
    • enable_callbacks
    • clear_all_callbacks
  • Convolution
    • Convolution
    • Pooling
    • Transpose
    • Copy
  • BOLD monitoring
    • BoldMonitor
    • BoldModel
    • balloon_RN
    • balloon_RL
    • balloon_CN
    • balloon_CL
    • balloon_maith2021
    • balloon_two_inputs
  • Tensorboard logging
    • Logger
  • ANN-to-SNN conversion
    • ANNtoSNNConverter

On this page

  • VideoPopulation
    • Parameters
    • Methods
      • grab_image
      • release
      • start_camera

VideoPopulation

extensions.image.ImagePopulation.VideoPopulation(
    self,
    geometry,
    opencv_version='4',
    name=None,
    copied=False,
)

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

pop = VideoPopulation(geometry=(480, 640))

compile()

pop.start_camera(0)

while(True):
    pop.grab_image()
    simulate(10.0)

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
grab_image Grabs one image from the camera and feeds it into the population.
release Releases the camera:
start_camera Starts the webcam with the corresponding device (default = 0).

grab_image

extensions.image.ImagePopulation.VideoPopulation.grab_image()

Grabs one image from the camera and feeds it into the population.

The camera must be first started with:

pop.start_camera(0)

release

extensions.image.ImagePopulation.VideoPopulation.release()

Releases the camera:

pop.release()

start_camera

extensions.image.ImagePopulation.VideoPopulation.start_camera(camera_port=0)

Starts the webcam with the corresponding device (default = 0).

On linux, the camera port corresponds to the number in /dev/video0, /dev/video1, etc.

ImagePopulation
save
 

Copyright Julien Vitay, Helge Ülo Dinkelbach, Fred Hamker