Reality Capture API get JSON parse error after authorize!

Reality Capture API get JSON parse error after authorize!

Anonymous
Not applicable
2,527 Views
10 Replies
Message 1 of 11

Reality Capture API get JSON parse error after authorize!

Anonymous
Not applicable

I've trying to use the Reality Caputre API to convert 2d photo to 3d model with example on:

https://github.com/Autodesk-Forge/photo-to-3d-sample

 

But when after I finish authorize, the browser cannot load the explore.ejs engine with error at the console:

SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)
at C:\Users\hongducphan\Desktop\photo-to-3d-sample\phototo3d.js:79:33
at Request.handleRequestResponse [as _callback] (C:\Users\hongducphan\Desktop\photo-to-3d-sample\node_modules\unirest\index.js:463:26)
at Request.self.callback (C:\Users\hongducphan\Desktop\photo-to-3d-sample\node_modules\request\request.js:187:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (C:\Users\hongducphan\Desktop\photo-to-3d-sample\node_modules\request\request.js:1044:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (C:\Users\hongducphan\Desktop\photo-to-3d-sample\node_modules\request\request.js:965:12)
200 - [object Object]

 

Please help me, I really need this api to use for my project.

0 Likes
Accepted solutions (3)
2,528 Views
10 Replies
Replies (10)
Message 2 of 11

anil_mistry
Autodesk Support
Autodesk Support

Hi @Anonymous,

 

Thank you for participating in our Community! I will forward this to our development team and will give you an update as soon as possible.

 

Thank you and have a great day!



Anil Mistry
Technical Support Specialist
Message 3 of 11

Anonymous
Not applicable

Thank you a lot anil.mistry!! I hope this bug will fix soon.

Thank you very much.

0 Likes
Message 4 of 11

eugene.chua
Autodesk
Autodesk
Accepted solution

Hi,

 

Sorry for the inconvenience! Some recent "Content-Type" header updates on our service broke our sample.

 

I've posted the fixes on my GitHub fork https://github.com/eugene-chua/photo-to-3D-sample

 

 

HTH,

 

-Eugene

Message 5 of 11

Anonymous
Not applicable

Hi @eugene.chua

Thanks a lot for your support. The project is now working but I don't understand after following the instruction until I press the "get result" button, It's return a message include an error code:

Error":{"code":"22","msg":"Data is not ready"}

I don't know this thing is problem or an api is working? And the result of this project is return the 3d model object or only the JSON data? Please help.

 

Thank you.

0 Likes
Message 6 of 11

eugene.chua
Autodesk
Autodesk
Accepted solution

That's good news!

 

You scene is currently processing. If you click on the "Get Results" button after a few minutes, you should get a valid download link in the response.

Message 7 of 11

Anonymous
Not applicable

Great! The problem was solved! Thank you very much @eugene.chua. Can you explain me how can I get the photo from my local computer, not from aws link in phototo3d.js? I've tried to override these link but it's cannot convert. Please help.

0 Likes
Message 8 of 11

eugene.chua
Autodesk
Autodesk
For direct file uploads, you can refer to the “Step 3 - Uploading Files Directly” section of the tutorial https://developer.autodesk.com/en/docs/reality-capture/v1/tutorials/create-3d-mesh-from-photos/

If you are familiar with cURL, you would need to make a call similar to ...

curl -v 'https://developer.api.autodesk.com/photo-to-3d/v1/file' \
-X 'POST' \
-H 'Authorization: Bearer eyjhbGCIOIjIuzI1NiISimtpZCI6...' \
-F "photosceneid=hcYJcrnHUsNSPII9glhVe8lRF6lFXs4NHzGqJ3zdWMU" \
-F "type=image" \
-F "file[0]=@c:/sample_data/_MG_9026.jpg" \
-F "file[1]=@c:/sample_data/_MG_9027.jpg"

To prevent timeouts, I would recommend uploading only one file at a time (instead of multiple files in a single call)
Message 9 of 11

anil_mistry
Autodesk Support
Autodesk Support

Hi @Anonymous,

 

Thank you for your reply and I am glad to hear that the issue is now resolved. Please, let us know if you have any other concerns or questions.

 

Thank you and have a great day!



Anil Mistry
Technical Support Specialist
Message 10 of 11

Anonymous
Not applicable

Hi @eugene.chua,

 

When I try to upload images directly from my local computer like the image. It was cause an error: "500 - Internal server error" and the console return a message: "200 - [object Object]".

 

I don't know what problem was affect this. Please help.

 

Code file:

https://drive.google.com/open?id=1s4ckF3VGN8SXi45mad9ieJKEAQBVXeSK

0 Likes
Message 11 of 11

eugene.chua
Autodesk
Autodesk
Accepted solution

@Anonymous

 

If you are modifying the node.js sample code, you will have to use the Uploading Files feature of the unirest library (http://unirest.io/nodejs.html), for example ...

 

 

	unirest.post(endpoint)
	.header('Accept', 'application/json')
	.header('Content-Type', 'multipart/form-data')
	.header('Authorization', 'Bearer ' + access_token)
	.field('type', 'image')
	.field('photosceneid', sceneId)
	.attach('file[0]', urlArray[0])
	.attach('file[1]', urlArray[1])

 

 

You should also remove the '@' prefix from your file paths.