|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.rim.device.api.amms.control.camera.ImageScanner
public class ImageScanner
This class is intended for scanning camera frames.
You'll want to grab the Field returned by ImageScanner.getViewfinder() and add it to your screen
before scanning is started. This Field can be configured through the VideoControl supplied by
ImageScanner.getVideoControl().
You are notified via the ImageDecoderListener when something has been detected by the set ImageDecoder.
Scanning is stopped automatically in the following scenarios:
Screen the viewfinder is attached to is detached from its UiEngine. Application that's displaying the viewfinder is moved to the background
(and in this scenario, the Screen displaying the viewfinder is also detached from its UiEngine.) ImageDecoder returns non null. The camera player will still be in the started state after ImageScanner.stopScan() is called, but the decoder is no longer processing until
ImageScanner.startScan() is called again. You will know when the decoder is processing data by the LED flashing red. If you wish to enable
continuous scanning, you should call startScan again a short delay after being notified that an image has been processed.
startScan and stopScan should be called from your application's event thread. The startScan method is non blocking and the scanning API is executed by a background thread already.
ImageDecoderListener listener = new ImageDecoderListener() {
private Runnable _restart = new Runnable() {
public void run() {
_scanner.startScan();
}
};
public void imageDecoded( Object decoded ) {
// restart the scanner in 250ms
Application.getApplication.invokeLater( _restart, 250, false );
// process what's been decoded
}
};
If you don't intend to reuse the scanner object after scanning has stopped, ensure you free up resources by calling getPlayer().close(). Once a player is closed it cannot be reused for scanning.
| Constructor Summary | ||
|---|---|---|
ImageScanner(ImageDecoder decoder,
ImageDecoderListener listener)
Constructs an ImageScanner. |
||
| Method Summary | ||
|---|---|---|
ImageDecoder |
getDecoder()
Returns the decoder. |
|
Player |
getPlayer()
Retrieves the camera player. |
|
VideoControl |
getVideoControl()
Retrieves the VideoControl for the player returned by getPlayer(). |
|
Field |
getViewfinder()
Retrieves the viewfinder for the VideoControl returned by getVideoControl(). |
|
static boolean |
isColorIncluded()
Whether there's a U & V component provided to ImageDecoder. |
|
boolean |
isScanning()
Queries if scanning is started. |
|
void |
setDecoder(ImageDecoder decoder)
Set the decoder. |
|
void |
setHint(ImageScannerHint hint)
Sets a scanning hint that is applied when scanning is started. |
|
void |
startScan()
Starts scanning for something your decoder can decode. |
|
void |
stopScan()
Stops scanning. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ImageScanner(ImageDecoder decoder,
ImageDecoderListener listener)
throws IOException,
MediaException
decoder - decoder responsible for decoding.listener - listener notified when decoder is successful.
IllegalArgumentException - if decoder or listener is null
SecurityException - if the caller does not have security permission to create the Player.
MediaException - if Manager.createPlayer(java.lang.String) throws it when specified "capture://video?encoding=image/jpeg".
IOException - if there was a problem connecting with the source pointed to by the locator.| Method Detail |
|---|
public Player getPlayer()
null.public VideoControl getVideoControl()
VideoControl for the player returned by getPlayer().
VideoControl for the player returned by getPlayer(),
will not be null.public Field getViewfinder()
VideoControl returned by getVideoControl().
VideoControl returned by getVideoControl(),
will not be null.
public void startScan()
throws MediaException
MediaException - if the Player cannot be started or scanning cannot be started.
IllegalStateException - if no ImageDecoder has been set, or if the Player
is in the CLOSED state.
SecurityException - if the caller does not have security permission to start the Player.
public void stopScan()
throws MediaException
MediaException - if the Player cannot be stopped or scanning cannot be stopped.
IllegalStateException - if the Player is in the CLOSED state.public boolean isScanning()
true if scanning is started, false otherwise.public static boolean isColorIncluded()
ImageDecoder.
true if U & V channels are provided, false otherwise.
public void setDecoder(ImageDecoder decoder)
throws IllegalArgumentException
decoder - the image decoder.
IllegalArgumentException - if decoder is null.ImageScanner.getDecoder()public ImageDecoder getDecoder()
ImageScanner.setDecoder(net.rim.device.api.amms.control.camera.ImageDecoder)public void setHint(ImageScannerHint hint)
hint - A hint from ImageScannerHint, can be null for no hints.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal