@@ -96,8 +96,9 @@ public final class ObjectDetector extends BaseVisionTaskApi {
9696 *
9797 * @param modelPath path to the detection model with metadata in the assets
9898 * @throws IOException if an I/O error occurs when loading the tflite model
99- * @throws AssertionError if error occurs when creating {@link ObjectDetector} from the native
100- * code
99+ * @throws IllegalArgumentException if an argument is invalid
100+ * @throws IllegalStateException if there is an internal error
101+ * @throws RuntimeException if there is an otherwise unspecified error
101102 */
102103 public static ObjectDetector createFromFile (Context context , String modelPath )
103104 throws IOException {
@@ -109,8 +110,9 @@ public static ObjectDetector createFromFile(Context context, String modelPath)
109110 *
110111 * @param modelFile the detection model {@link File} instance
111112 * @throws IOException if an I/O error occurs when loading the tflite model
112- * @throws AssertionError if error occurs when creating {@link ObjectDetector} from the native
113- * code
113+ * @throws IllegalArgumentException if an argument is invalid
114+ * @throws IllegalStateException if there is an internal error
115+ * @throws RuntimeException if there is an otherwise unspecified error
114116 */
115117 public static ObjectDetector createFromFile (File modelFile ) throws IOException {
116118 return createFromFileAndOptions (modelFile , ObjectDetectorOptions .builder ().build ());
@@ -122,10 +124,9 @@ public static ObjectDetector createFromFile(File modelFile) throws IOException {
122124 *
123125 * @param modelBuffer a direct {@link ByteBuffer} or a {@link MappedByteBuffer} of the detection
124126 * model
125- * @throws AssertionError if error occurs when creating {@link ObjectDetector} from the native
126- * code
127127 * @throws IllegalArgumentException if the model buffer is not a direct {@link ByteBuffer} or a
128- * {@link MappedByteBuffer}
128+ * {@link MappedByteBuffer} * @throws IllegalStateException if there is an internal error
129+ * @throws RuntimeException if there is an otherwise unspecified error
129130 */
130131 public static ObjectDetector createFromBuffer (final ByteBuffer modelBuffer ) {
131132 return createFromBufferAndOptions (modelBuffer , ObjectDetectorOptions .builder ().build ());
@@ -136,8 +137,9 @@ public static ObjectDetector createFromBuffer(final ByteBuffer modelBuffer) {
136137 *
137138 * @param modelPath path to the detection model with metadata in the assets
138139 * @throws IOException if an I/O error occurs when loading the tflite model
139- * @throws AssertionError if error occurs when creating {@link ObjectDetector} from the native
140- * code
140+ * @throws IllegalArgumentException if an argument is invalid
141+ * @throws IllegalStateException if there is an internal error
142+ * @throws RuntimeException if there is an otherwise unspecified error
141143 */
142144 public static ObjectDetector createFromFileAndOptions (
143145 Context context , String modelPath , ObjectDetectorOptions options ) throws IOException {
@@ -170,8 +172,9 @@ public long createHandle(
170172 *
171173 * @param modelFile the detection model {@link File} instance
172174 * @throws IOException if an I/O error occurs when loading the tflite model
173- * @throws AssertionError if error occurs when creating {@link ObjectDetector} from the native
174- * code
175+ * @throws IllegalArgumentException if an argument is invalid
176+ * @throws IllegalStateException if there is an internal error
177+ * @throws RuntimeException if there is an otherwise unspecified error
175178 */
176179 public static ObjectDetector createFromFileAndOptions (
177180 File modelFile , final ObjectDetectorOptions options ) throws IOException {
@@ -201,10 +204,10 @@ public long createHandle() {
201204 *
202205 * @param modelBuffer a direct {@link ByteBuffer} or a {@link MappedByteBuffer} of the detection
203206 * model
204- * @throws AssertionError if error occurs when creating {@link ObjectDetector} from the native
205- * code
206207 * @throws IllegalArgumentException if the model buffer is not a direct {@link ByteBuffer} or a
207208 * {@link MappedByteBuffer}
209+ * @throws IllegalStateException if there is an internal error
210+ * @throws RuntimeException if there is an otherwise unspecified error
208211 */
209212 public static ObjectDetector createFromBufferAndOptions (
210213 final ByteBuffer modelBuffer , final ObjectDetectorOptions options ) {
@@ -328,8 +331,8 @@ public Builder setScoreThreshold(float scoreThreshold) {
328331 *
329332 * <p>If non-empty, detection results whose label is not in this set will be filtered out.
330333 * Duplicate or unknown labels are ignored. Mutually exclusive with {@code labelDenyList}. It
331- * will cause {@link AssertionError } when calling {@link #createFromFileAndOptions}, if both
332- * {@code labelDenyList} and {@code labelAllowList} are set.
334+ * will cause {@link IllegalStateException } when calling {@link #createFromFileAndOptions}, if
335+ * both {@code labelDenyList} and {@code labelAllowList} are set.
333336 */
334337 public Builder setLabelAllowList (List <String > labelAllowList ) {
335338 this .labelAllowList = Collections .unmodifiableList (new ArrayList <>(labelAllowList ));
@@ -341,8 +344,8 @@ public Builder setLabelAllowList(List<String> labelAllowList) {
341344 *
342345 * <p>If non-empty, detection results whose label is in this set will be filtered out.
343346 * Duplicate or unknown labels are ignored. Mutually exclusive with {@code labelAllowList}. It
344- * will cause {@link AssertionError } when calling {@link #createFromFileAndOptions}, if both
345- * {@code labelDenyList} and {@code labelAllowList} are set.
347+ * will cause {@link IllegalStateException } when calling {@link #createFromFileAndOptions}, if
348+ * both {@code labelDenyList} and {@code labelAllowList} are set.
346349 */
347350 public Builder setLabelDenyList (List <String > labelDenyList ) {
348351 this .labelDenyList = Collections .unmodifiableList (new ArrayList <>(labelDenyList ));
@@ -435,7 +438,8 @@ private ObjectDetectorOptions(Builder builder) {
435438 * </ul>
436439 *
437440 * @param image a UINT8 {@link TensorImage} object that represents an RGB or YUV image
438- * @throws AssertionError if error occurs when processing the image from the native code
441+ * @throws IllegalStateException if there is an internal error
442+ * @throws RuntimeException if there is an otherwise unspecified error
439443 * @throws IllegalArgumentException if the color space type of image is unsupported
440444 */
441445 public List <Detection > detect (TensorImage image ) {
@@ -464,7 +468,8 @@ public List<Detection> detect(TensorImage image) {
464468 *
465469 * @param image a UINT8 {@link TensorImage} object that represents an RGB or YUV image
466470 * @param options the options to configure how to preprocess the image
467- * @throws AssertionError if error occurs when processing the image from the native code
471+ * @throws IllegalStateException if there is an internal error
472+ * @throws RuntimeException if there is an otherwise unspecified error
468473 * @throws IllegalArgumentException if the color space type of image is unsupported
469474 */
470475 public List <Detection > detect (TensorImage image , ImageProcessingOptions options ) {
@@ -484,7 +489,8 @@ public List<Detection> run(
484489 * Performs actual detection on the provided {@code MlImage}.
485490 *
486491 * @param image an {@code MlImage} object that represents an image
487- * @throws AssertionError if error occurs when processing the image from the native code
492+ * @throws IllegalStateException if there is an internal error
493+ * @throws RuntimeException if there is an otherwise unspecified error
488494 * @throws IllegalArgumentException if the storage type or format of the image is unsupported
489495 */
490496 public List <Detection > detect (MlImage image ) {
@@ -504,7 +510,8 @@ public List<Detection> detect(MlImage image) {
504510 *
505511 * @param image an {@code MlImage} object that represents an image
506512 * @param options the options to configure how to preprocess the image
507- * @throws AssertionError if error occurs when classifying the image from the native code
513+ * @throws IllegalStateException if there is an internal error
514+ * @throws RuntimeException if there is an otherwise unspecified error
508515 * @throws IllegalArgumentException if the storage type or format of the image is unsupported
509516 */
510517 public List <Detection > detect (MlImage image , ImageProcessingOptions options ) {
0 commit comments