com.craftar
Class CloudSearchController
- java.lang.Object
-
- HandlerThread
-
- com.craftar.CloudSearchController
-
- All Implemented Interfaces:
- CraftARCamera.CraftARCameraCallbacks, SearchController
public class CloudSearchController extends HandlerThread implements SearchController
SearchController
used for cloud-image recognition. ThisSearchController
will take the frames from the camera feed, and perform image recognition on them. By default, it performs at most 2 searches per second. You can reduce this by configuring the search period using the functionsetSearchPeriod
When a search request is still pending, thisSearchController
will ignore all the coming frames until the last search request finishes.
-
-
Constructor Summary
Constructors Constructor and Description CloudSearchController(CraftARCloudRecognition cloudIR)
Creates a newCloudSearchController
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Handler
getHandler()
void
onFinderActivated()
On Finder activated, theCloudSearchController
start processing the frames received inonPreviewFrame(CraftARQueryImage)
void
onFinderDeactivated()
On Finder deactivated, theCloudSearchController
will ignore all the frames inonPreviewFrame(CraftARQueryImage)
void
onLooperPrepared()
void
onPictureTaken(CraftARQueryImage image)
Performs visual search with the picture taken.void
onPreviewFrame(CraftARQueryImage image)
Receives the frames from the camera, and performs visual search on them.void
onTakePictureFailed(CraftARError error)
If takePicture fails, this searchController will return an error in yourCraftARSearchResponseHandler.searchFailed(CraftARError,int)
method, but with request code -1.boolean
setSearchPeriod(long periodMs)
Modify the rate at which this SearchController performs searches.void
start()
-
-
-
Constructor Detail
-
CloudSearchController
public CloudSearchController(CraftARCloudRecognition cloudIR)
Creates a newCloudSearchController
-
-
Method Detail
-
start
public void start()
-
onLooperPrepared
public void onLooperPrepared()
-
getHandler
public Handler getHandler()
-
onFinderActivated
public void onFinderActivated()
On Finder activated, theCloudSearchController
start processing the frames received inonPreviewFrame(CraftARQueryImage)
- Specified by:
onFinderActivated
in interfaceSearchController
-
onFinderDeactivated
public void onFinderDeactivated()
On Finder deactivated, theCloudSearchController
will ignore all the frames inonPreviewFrame(CraftARQueryImage)
- Specified by:
onFinderDeactivated
in interfaceSearchController
-
onPictureTaken
public void onPictureTaken(CraftARQueryImage image)
Performs visual search with the picture taken.- Specified by:
onPictureTaken
in interfaceCraftARCamera.CraftARCameraCallbacks
- Parameters:
image
- The picture taken
-
setSearchPeriod
public boolean setSearchPeriod(long periodMs)
Modify the rate at which this SearchController performs searches. This SearchController will search only when there are no previous petitions pending.- Parameters:
periodMs
- requested period in ms (must be >= 500ms , which means a maximum of 2 requests/second).- Returns:
- true if the search period was succesfully modified, false otherwise.
-
onPreviewFrame
public void onPreviewFrame(CraftARQueryImage image)
Receives the frames from the camera, and performs visual search on them. If finding enabled, theCloudSearchController
will perform visual recognition on a frame once the last image recognition request has been completed, and after a given time has passed since the last request sent. If a previous recognition request is still pending, or the last recognition request occurred earlier than a given time (default 500ms), the frame will be ignored. You can configure this time using the functionsetSearchPeriod()
You can implement your own search controller if you want to modify this behaviour.- Specified by:
onPreviewFrame
in interfaceCraftARCamera.CraftARCameraCallbacks
- Parameters:
image
- The frame from the camera
-
onTakePictureFailed
public void onTakePictureFailed(CraftARError error)
If takePicture fails, this searchController will return an error in yourCraftARSearchResponseHandler.searchFailed(CraftARError,int)
method, but with request code -1.- Specified by:
onTakePictureFailed
in interfaceCraftARCamera.CraftARCameraCallbacks
- Parameters:
error
- Error describing the problem.
-
-