SCAMP-5c Vision System  1.0.0
An image sensor with a parallel processor on focal plane
Data Structures | Functions
host_and_sim.h File Reference

Go to the source code of this file.

Data Structures

class  handle
 variable of this type is a handle to a APRON UI object More...
 

Functions

 apron_config_begin ()
 this function start the configuration section of the script
 
 apron_config_end ()
 this function finish the configuration section of the script
 
 sim_pix_source_webcam ()
 use a webcam as the image source when running as simulation
 
 sim_pix_source_image (string path)
 use an image as the image source when running as simulation
 
 sim_pix_source_video (string path)
 use a video as the image source when running as simulation
 
 sim_use_error_model (int v)
 set the level of error model to use in simulation More...
 
 host_set_frame_rate (int v)
 set the desired frame rate More...
 
handle host_add_display (string text)
 add a display window to the APRON UI More...
 
handle host_add_display (string text, string palette)
 similar to host_add_display but with a specific palette name More...
 
 host_record_display (handle h, string path, int n)
 save frames received in a display More...
 
handle host_add_datasheet (string text, int r, int c, enum d)
 add a datasheet to the APRON host More...
 
handle host_add_slider (string text, int min, int max, int init)
 add a slider to the APRON UI More...
 
handle host_add_slider (string text, int min, int max, int init, int spi_name, int is_latched)
 host_add_slider with two extra arguments to enable the slider to be created in SPI Host App More...
 

Detailed Description

Author
Jianing Chen

Function Documentation

sim_use_error_model ( int  v)

set the level of error model to use in simulation

Parameters
vlevel of error model
Level Error Included
0 none
1 transfer error and IN error
2 soft saturation
3 mismatch error
host_set_frame_rate ( int  v)

set the desired frame rate

Parameters
vthe frame rate

Note, this only affect the frame trigger. In a loop with frame readout macros ( aout and dout), the actual visible frame rate is much lower than the setting because the frame readout take a lot of time.

The following structure can be used to keep the exposure time to be (1/framerate):

1 ...
2 host.set_frame_rate(50)// 50 frames per sec
3 ...
4 
5 #frame_loop
6 
7  // maintain an exposure time of 1/50 sec
8  ipu.wait_frame_trigger
9  pe.rpix
10  ipu.wait_frame_trigger
11  pe.rpix(B,C)
12 
13  // the rest of the program
14  ...
15 
16 _jump(#frame_loop)
handle host_add_display ( string  text)

add a display window to the APRON UI

Parameters
textname of the display
Returns
handle of the display window

Use this function to create a window in APRON UI that can show an image (register array) received from the program. For example,

1 apron.config_begin
2 window_1 = host.add_display('Captured')
3 apron.config_end

create a window that can be referred as window_1.

In the program, a particular register for each of the PEs can be read as a image. For example,

1 usb.aout(C,window_1)

send analogue register C to window_1 of the APRON hosting UI as an image of 256x256. See also usb_aout.

handle host_add_display ( string  text,
string  palette 
)

similar to host_add_display but with a specific palette name

Parameters
textname of the display
palettename of the palette
Returns
handle of the display window
host_record_display ( handle  h,
string  path,
int  n 
)

save frames received in a display

Parameters
hhandle of the display
pathpath and filename of the saved image file
nmaximum number of image saved

Save each of the frame received in a display as a BMP file. Any folders in the path need to be created manually.

Example Usage:

The following configuration enables the first 100 frames received in window_1 to be saved in the folder "snapshots". The name of the image files are "out_1.bmp" to "out_100.bmp".

1 window_1 = host.add_display('out')
2 host.record_display(window_1,'snapshots/out_',100)
handle host_add_datasheet ( string  text,
int  r,
int  c,
enum  d 
)

add a datasheet to the APRON host

Parameters
textname of the datasheet
rnumber of rows
cnumber of cols
ddirection of data to be filled via streaming
Returns
handle of the datasheet

Create a datasheet in the host to store incoming data stream. See also usb_stream_begin .

handle host_add_slider ( string  text,
int  min,
int  max,
int  init 
)

add a slider to the APRON UI

Parameters
texttext showing on the slider
minminimum value of the slider, ranged in [0,255]
maxmaximum value of the slider, ranged in [0,255]
initinitial value of the slider, ranged in [0,255]
Returns
handle of the slider

Use this function to create a slider in APRON UI to send a parameter to the program in both simulation and real hardware. For example,

1 apron.config_begin
2 slider_1 = host.add_slider('parameter a', 0, 255, 127)
3 apron.config_end

create a slider that can be referred as slider_1.

In the program, the value presented on a slider can be obtained and stored in an IPU register. For example,

1 s0 = usb.slider(slider_1)

put the value on slider_1 into ipu register s0. See also usb_slider.

handle host_add_slider ( string  text,
int  min,
int  max,
int  init,
int  spi_name,
int  is_latched 
)

host_add_slider with two extra arguments to enable the slider to be created in SPI Host App

Parameters
texttext showing on the slider
minminimum value of the slider, ranged in [0,255]
maxmaximum value of the slider, ranged in [0,255]
initinitial value of the slider, ranged in [0,255]
spi_nameindex of the name string to be displayed in SPI Host App
is_latchedis the value latched (update only when the handle is released)
Returns
handle of the slider

The viable definition of the spi name index:

Macro Definition Number
SPI_APP_TEXT_NOT_AVAILABLE 0
SPI_APP_TEXT_UNDEFINED 1
SPI_APP_TEXT_SWITCH 2
SPI_APP_TEXT_MODE 3
SPI_APP_TEXT_THRESHOLD_A 4
SPI_APP_TEXT_THRESHOLD_B 5
SPI_APP_TEXT_THRESHOLD_C 6
SPI_APP_TEXT_THRESHOLD_D 7
SPI_APP_TEXT_X 8
SPI_APP_TEXT_Y 9
SPI_APP_TEXT_X_SHIFT 10
SPI_APP_TEXT_Y_SHIFT 11
SPI_APP_TEXT_X_MASK 12
SPI_APP_TEXT_Y_MASK 13
SPI_APP_TEXT_X_MATCH 14
SPI_APP_TEXT_Y_MATCH 15
SPI_APP_TEXT_INPUT_0 16
SPI_APP_TEXT_INPUT_1 17
SPI_APP_TEXT_INPUT_2 18
SPI_APP_TEXT_INPUT_3 19
SPI_APP_TEXT_ITERATION_I 20
SPI_APP_TEXT_ITERATION_J 21
SPI_APP_TEXT_EXPOSURE 22
SPI_APP_TEXT_DIFFUSION 23
SPI_APP_TEXT_E 24
SPI_APP_TEXT_F 25
SPI_APP_TEXT_G 26
SPI_APP_TEXT_H 27
SPI_APP_TEXT_T 28
SPI_APP_TEXT_U 29
SPI_APP_TEXT_V 30
SPI_APP_TEXT_W 31