Foreground extraction iOS application. The app let's the user to select an image, extract foreground and upload the image object to the echo3D console.
If you don't have an echo3D API key yet, make sure to register for FREE at echo3D.
- Clone the project from the github repository.
- Open up Xcode and select 'open an existing project'.
- Connect an IOS Device and build the project.
-
There are two options at the top-right corner of the navigation bar.
- Photogallery: If you want to choose image from photo-gallery.
- Camera: If you choose to take an new image.
-
After choosing an image either from camera or photogallery, click "Begin Button" to start foreground extraction
-
If you wish to upload image to the echo3D console, click on the upload button at the top left corner.
If you want to add image upload functionality to your custom application, add APIRequest.swift
and Media.swift
to your project folder.
-
To make an http-post request create an
APIRequest
object:let postRequest = APIRequest()
-
To send the post request use
send()
instance method ofAPIRequest
, which accepts these parameters:image
(type: UIimage): The UIImage you need to upload to the consoleimageName
(type: String): The name of the imageechoARApiKey
(type: String) : Your API keycompletion
(type: closure): Escaping Closure which is passed as an arguement to the function but is called after function returns. It return Result type that has two cases: success and failure, where the success case will return a string and the failure case will be some sort of API Error.
let postRequest = APIRequest()
postRequest.send(imageToPost: UIimage,fileName: String, APIKey: String, completion: {
result in switch result {
case .success(_):
print("Success Uploading")
case .failure(.incorrectKeyProblem):
self.createErrorAlert("Incorrect Key", "Please Check key and Try again")
print("Incorrect Key")
case .failure(let error):
print("Error Occurred \(error)")
}
})
- Post Request performs
multipart/form-data
httpRequest, where key-value pair are seperated with the randomnly generated boundary string. - Post Request only works for
target_type = 2
,hologram_type = 1
and image is sent asfile_image_hologram
.
- Closure which is passed as an
send(_)
request return.success
or.failure
, where.failure
is type ofAPIError
:- responseProblem: Problem with the API Response
- decodingProblem: Error decoding API Response data
- incorrectKeyProblem: Incorrect API Key
Refer to our documentation to learn more about how to use Unity, AR Foundation, and echo3D.
Feel free to reach out at support@echo3D.co or join our support channel on Slack.