Bar code scanner widget. More...
Public Member Functions | |
Scanner () | |
void | Open (string device) |
Open a video device. | |
void | Close () |
void | ResetLastItemScanned () |
Resets the last item scanned. | |
Static Public Member Functions | |
static IDictionary< string, string > | ListVideoSources () |
List potential video sources on the system (Obsolete). | |
Protected Member Functions | |
override bool | OnExposeEvent (Gdk.EventExpose ev) |
override void | OnSizeAllocated (Gdk.Rectangle allocation) |
override void | OnSizeRequested (ref Gtk.Requisition requisition) |
Properties | |
bool | Mute [get, set] |
bool | Flip [get, set] |
Events | |
EventHandler | Stopped |
Occurs if an error occured during runtime and the video device stopped. | |
EventHandler< ErrorEventArgs > | Error |
Occurs if an error happens and user should be informed about this. | |
EventHandler< BarScannedArgs > | BarScanned |
Occurs whenever a bar code have been successfully scanned. | |
Private Member Functions | |
void | HandleDestroyed (object sender, EventArgs e) |
void | ProcessVideo () |
Process video, the worker thread. | |
void | CaptureVideo (Video video, ImageScanner scanner) |
Capture and scan images. | |
void | ThreadSafeRedraw () |
Simple threadsafe redraw method. | |
Private Attributes | |
string | currentDevice = null |
Temporary variable used to transfer argument to the ProcessVideo method. | |
System.Threading.Thread | worker = null |
Reference to the worker thread, so that we can kill it :). | |
System.Object | drawLock = new System.Object() |
Image access lock. | |
byte[] | toDraw = null |
Image to draw. | |
int | toDrawWidth |
Image width. | |
int | toDrawHeight |
Image height. | |
List< Symbol > | symbols = null |
Symbols found in the image. | |
string | data = null |
const int | overlayFrameCount = 35 |
int | overlayingFrames = 0 |
Pixbuf | overlay = Pixbuf.LoadFromResource("FoodRegistration.check.png") |
Pixbuf | sourceMissing = Pixbuf.LoadFromResource("FoodRegistration.webcam.png") |
int | AllocatedWidth |
int | AllocatedHeight |
int | reqHeight = 200 |
int | reqWidth = 200 |
Bar code scanner widget.
This widget uses a thread to pull the video device, so it is important to destroy it correctly.
Definition at line 20 of file Scanner.cs.
Foodolini.Activities.FoodRegistration.Scanner.Scanner | ( | ) |
Definition at line 22 of file Scanner.cs.
void Foodolini.Activities.FoodRegistration.Scanner.CaptureVideo | ( | Video | video, | |
ImageScanner | scanner | |||
) | [private] |
Capture and scan images.
This method will also flip the images so that they need not be flipped when drawing.
Definition at line 149 of file Scanner.cs.
void Foodolini.Activities.FoodRegistration.Scanner.Close | ( | ) |
Definition at line 63 of file Scanner.cs.
void Foodolini.Activities.FoodRegistration.Scanner.HandleDestroyed | ( | object | sender, | |
EventArgs | e | |||
) | [private] |
Definition at line 26 of file Scanner.cs.
static IDictionary<string, string> Foodolini.Activities.FoodRegistration.Scanner.ListVideoSources | ( | ) | [static] |
List potential video sources on the system (Obsolete).
This just adds a default device without checking it's existance on Windows. On Linux this list all /dev/video* devices, and attempts to get their name using /lib/udev/v4l_id, watch the kernel source (link available in source comments) to that this remains compatible.
Alternately, define UDEV_RULES and the "/dev/v4l/by-id/" symlinks will be used to find the names. Note this presumably depends on Ubuntu 9.10 udev rules. Thus the other approach is preffered.
Note that on Linux this might be solve a lot better using HAL over dbus, however, last I checked HAL is being replaced by DeviceKit which isn't done yet, so unless the APIs are expected to remain stable HAL is a waste of time.
Definition at line 374 of file Scanner.cs.
override bool Foodolini.Activities.FoodRegistration.Scanner.OnExposeEvent | ( | Gdk.EventExpose | ev | ) | [protected] |
Definition at line 228 of file Scanner.cs.
override void Foodolini.Activities.FoodRegistration.Scanner.OnSizeAllocated | ( | Gdk.Rectangle | allocation | ) | [protected] |
Definition at line 321 of file Scanner.cs.
override void Foodolini.Activities.FoodRegistration.Scanner.OnSizeRequested | ( | ref Gtk.Requisition | requisition | ) | [protected] |
Definition at line 333 of file Scanner.cs.
void Foodolini.Activities.FoodRegistration.Scanner.Open | ( | string | device | ) |
Open a video device.
device | Video device to open |
Definition at line 55 of file Scanner.cs.
void Foodolini.Activities.FoodRegistration.Scanner.ProcessVideo | ( | ) | [private] |
Process video, the worker thread.
Definition at line 114 of file Scanner.cs.
void Foodolini.Activities.FoodRegistration.Scanner.ResetLastItemScanned | ( | ) |
Resets the last item scanned.
This method may only be called from UI-thread.
Definition at line 224 of file Scanner.cs.
void Foodolini.Activities.FoodRegistration.Scanner.ThreadSafeRedraw | ( | ) | [private] |
Simple threadsafe redraw method.
Definition at line 190 of file Scanner.cs.
Definition at line 328 of file Scanner.cs.
Definition at line 327 of file Scanner.cs.
string Foodolini.Activities.FoodRegistration.Scanner.currentDevice = null [private] |
Temporary variable used to transfer argument to the ProcessVideo method.
Definition at line 47 of file Scanner.cs.
string Foodolini.Activities.FoodRegistration.Scanner.data = null [private] |
Definition at line 214 of file Scanner.cs.
System.Object Foodolini.Activities.FoodRegistration.Scanner.drawLock = new System.Object() [private] |
Image access lock.
Definition at line 85 of file Scanner.cs.
Pixbuf Foodolini.Activities.FoodRegistration.Scanner.overlay = Pixbuf.LoadFromResource("FoodRegistration.check.png") [private] |
Definition at line 217 of file Scanner.cs.
const int Foodolini.Activities.FoodRegistration.Scanner.overlayFrameCount = 35 [private] |
Definition at line 215 of file Scanner.cs.
int Foodolini.Activities.FoodRegistration.Scanner.overlayingFrames = 0 [private] |
Definition at line 216 of file Scanner.cs.
int Foodolini.Activities.FoodRegistration.Scanner.reqHeight = 200 [private] |
Definition at line 330 of file Scanner.cs.
int Foodolini.Activities.FoodRegistration.Scanner.reqWidth = 200 [private] |
Definition at line 331 of file Scanner.cs.
Pixbuf Foodolini.Activities.FoodRegistration.Scanner.sourceMissing = Pixbuf.LoadFromResource("FoodRegistration.webcam.png") [private] |
Definition at line 218 of file Scanner.cs.
List<Symbol> Foodolini.Activities.FoodRegistration.Scanner.symbols = null [private] |
byte [] Foodolini.Activities.FoodRegistration.Scanner.toDraw = null [private] |
System.Threading.Thread Foodolini.Activities.FoodRegistration.Scanner.worker = null [private] |
Reference to the worker thread, so that we can kill it :).
Definition at line 80 of file Scanner.cs.
bool Foodolini.Activities.FoodRegistration.Scanner.Flip [get, set] |
Flip the image vertically, default false
Our studies have shown that it is a lot easier to scan bar codes when the webcam is facing you if the image is flipped.
Definition at line 351 of file Scanner.cs.
bool Foodolini.Activities.FoodRegistration.Scanner.Mute [get, set] |
Mute
Definition at line 342 of file Scanner.cs.
EventHandler<BarScannedArgs> Foodolini.Activities.FoodRegistration.Scanner.BarScanned |
Occurs whenever a bar code have been successfully scanned.
Usually hardware related issues, as this is stuff the user must handle.
Definition at line 212 of file Scanner.cs.
EventHandler<ErrorEventArgs> Foodolini.Activities.FoodRegistration.Scanner.Error |
Occurs if an error happens and user should be informed about this.
Definition at line 206 of file Scanner.cs.
EventHandler Foodolini.Activities.FoodRegistration.Scanner.Stopped |
Occurs if an error occured during runtime and the video device stopped.
Definition at line 201 of file Scanner.cs.