@@ -575,6 +575,84 @@ private void OnDeleteCollectionResponse(RESTConnector.Request req, RESTConnector
575
575
( ( RequestObject < object > ) req ) . Callback ( response , resp . Error ) ;
576
576
}
577
577
/// <summary>
578
+ /// Get a model.
579
+ ///
580
+ /// Download a model that you can deploy to detect objects in images. The collection must include a generated
581
+ /// model, which is indicated in the response for the collection details as `"rscnn_ready": true`. If the value
582
+ /// is `false`, train or retrain the collection to generate the model.
583
+ ///
584
+ /// Currently, the model format is specific to Android apps. For more information about how to deploy the model
585
+ /// to your app, see the [Watson Visual Recognition on Android](https://github.com/matt-ny/rscnn) project in
586
+ /// GitHub.
587
+ /// </summary>
588
+ /// <param name="callback">The callback function that is invoked when the operation completes.</param>
589
+ /// <param name="collectionId">The identifier of the collection.</param>
590
+ /// <param name="feature">The feature for the model.</param>
591
+ /// <param name="modelFormat">The format of the returned model.</param>
592
+ /// <returns><see cref="byte[]" />byte[]</returns>
593
+ public bool GetModelFile ( Callback < byte [ ] > callback , string collectionId , string feature , string modelFormat )
594
+ {
595
+ if ( callback == null )
596
+ throw new ArgumentNullException ( "`callback` is required for `GetModelFile`" ) ;
597
+ if ( string . IsNullOrEmpty ( collectionId ) )
598
+ throw new ArgumentNullException ( "`collectionId` is required for `GetModelFile`" ) ;
599
+ if ( string . IsNullOrEmpty ( feature ) )
600
+ throw new ArgumentNullException ( "`feature` is required for `GetModelFile`" ) ;
601
+ if ( string . IsNullOrEmpty ( modelFormat ) )
602
+ throw new ArgumentNullException ( "`modelFormat` is required for `GetModelFile`" ) ;
603
+
604
+ RequestObject < byte [ ] > req = new RequestObject < byte [ ] >
605
+ {
606
+ Callback = callback ,
607
+ HttpMethod = UnityWebRequest . kHttpVerbGET ,
608
+ DisableSslVerification = DisableSslVerification
609
+ } ;
610
+
611
+ foreach ( KeyValuePair < string , string > kvp in customRequestHeaders )
612
+ {
613
+ req . Headers . Add ( kvp . Key , kvp . Value ) ;
614
+ }
615
+
616
+ ClearCustomRequestHeaders ( ) ;
617
+
618
+ foreach ( KeyValuePair < string , string > kvp in Common . GetSdkHeaders ( "watson_vision_combined" , "V4" , "GetModelFile" ) )
619
+ {
620
+ req . Headers . Add ( kvp . Key , kvp . Value ) ;
621
+ }
622
+
623
+ req . Parameters [ "version" ] = VersionDate ;
624
+ if ( ! string . IsNullOrEmpty ( feature ) )
625
+ {
626
+ req . Parameters [ "feature" ] = feature ;
627
+ }
628
+ if ( ! string . IsNullOrEmpty ( modelFormat ) )
629
+ {
630
+ req . Parameters [ "model_format" ] = modelFormat ;
631
+ }
632
+
633
+ req . OnResponse = OnGetModelFileResponse ;
634
+
635
+ Connector . URL = GetServiceUrl ( ) + string . Format ( "/v4/collections/{0}/model" , collectionId ) ;
636
+ Authenticator . Authenticate ( Connector ) ;
637
+
638
+ return Connector . Send ( req ) ;
639
+ }
640
+
641
+ private void OnGetModelFileResponse ( RESTConnector . Request req , RESTConnector . Response resp )
642
+ {
643
+ DetailedResponse < byte [ ] > response = new DetailedResponse < byte [ ] > ( ) ;
644
+ foreach ( KeyValuePair < string , string > kvp in resp . Headers )
645
+ {
646
+ response . Headers . Add ( kvp . Key , kvp . Value ) ;
647
+ }
648
+ response . StatusCode = resp . HttpResponseCode ;
649
+
650
+ response . Result = resp . Data ;
651
+
652
+ if ( ( ( RequestObject < byte [ ] > ) req ) . Callback != null )
653
+ ( ( RequestObject < byte [ ] > ) req ) . Callback ( response , resp . Error ) ;
654
+ }
655
+ /// <summary>
578
656
/// Add images.
579
657
///
580
658
/// Add images to a collection by URL, by file, or both.
0 commit comments