-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest.docstring
65 lines (45 loc) · 2.09 KB
/
request.docstring
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Requests an image from a camera for asynchronous capture
SYNOPSIS
from fltk import *
from Fl_Gl_Image_Widget import Fl_Gl_Image_Widget
camera = mrcam.camera()
def callback_image_ready(fd):
frame = camera.requested_image()
image_widget.update_image(image_data = frame['image'])
Fl.add_timeout(1., camera.request)
Fl.add_fd( camera.fd_image_ready,
callback_image_ready )
camera.request()
window = Fl_Window(800,600, "mrcam")
image_widget = Fl_Gl_Image_Widget(0,0, 800,600)
window.resizable(image_widget)
window.end()
window.show()
Fl.run()
### An interactive GUI window pops up, displaying the live camera feed at
### 1Hz
request() asks the camera to initiate an image capture, and to tell us when it
is done. The call will NOT block. This is critically important for applications
that need to be ready to do other work, notably GUI applications. To get images
synchronously, look at pull().
The image capture sequence is:
- camera.request() call is made to ask for a frame
- camera.fd_image_ready is a file descriptor that can be poll()-ed or
select()-ed. When the requested image is ready, this file descriptor becomes
ready for reading. In the main loop, an application would poll() ALL the
descriptors that potentially have work for the application to do (keyboard,
mouse, network, timerfd, mrcam, ...). When any of the descriptors get data to
be read, the application wakes up and does the necessary work. In the example
above we add this camera file descriptor to the set that the FLTK GUI waits
for by calling Fl.add_fd(...). When the requested image is ready, Fl.run()
wakes up and calls callback_image_ready()
- In callback_image_ready() we call camera.requested_image() to retrieve the
incoming image
This function normally cannot fail. Any image capture errors will be indicated
by requested_image()['image'] being None.
It is guaranteed that every request() call will be followed by a single response
that should be ingested by a single requested_image() call.
ARGUMENTS
None
RETURNED VALUE
None