質問編集履歴

2

JavaScript コード追加

2019/02/17 06:40

投稿

mypace
mypace

スコア45

test CHANGED
File without changes
test CHANGED
@@ -140,10 +140,156 @@
140
140
 
141
141
  });
142
142
 
143
+ // Route /api/forge/recap/photoscene/add
144
+
145
+ // Creates and initializes a photoscene for reconstruction.
146
+
147
+ app.get('/api/forge/recap/photoscene/add', function (req, res) {
148
+
149
+ Axios({
150
+
151
+ method: 'POST',
152
+
153
+ url: 'https://developer.api.autodesk.com/photo-to-3d/v1/photoscene',
154
+
155
+ headers: {
156
+
157
+ 'content-type': 'application/json',
158
+
159
+ 'Authorization': 'Bearer ' + access_token
160
+
161
+ },
162
+
163
+ data: querystring.stringify({
164
+
165
+ scenename: 'myscenename',
166
+
167
+ format: 'obj' //rcm->obj, ply
168
+
169
+ })
170
+
171
+ })
172
+
173
+ .then(function (response) {
174
+
175
+ // Success
176
+
177
+ console.log(response);
178
+
179
+ if (response.data.Error) {
180
+
181
+ res.send(response.data.Error.msg);
182
+
183
+ }
184
+
185
+ var photosceneId = response.data.Photoscene.photosceneid;
186
+
187
+ var nextLink = '/api/forge/recap/photoscene/upload?photosceneid=' + photosceneId;
188
+
189
+ res.send('<p>Photoscene added!</p><a href="' + nextLink + '">Upload files to photoscene</a>');
190
+
191
+ })
192
+
193
+ .catch(function (error) {
194
+
195
+ // Failed
196
+
197
+ console.log(error);
198
+
199
+ res.send('Failed to create a photoscene');
200
+
201
+ });
202
+
203
+ });
204
+
205
+
206
+
207
+ // Route /api/forge/recap/photoscene/upload
208
+
209
+ // Adds one or more files to a photoscene.
210
+
211
+ app.get('/api/forge/recap/photoscene/upload', function (req, res) {
212
+
213
+ var photosceneId = req.query.photosceneid;
214
+
215
+ Axios({
216
+
217
+ method: 'POST',
218
+
219
+ url: 'https://developer.api.autodesk.com/photo-to-3d/v1/file',
220
+
221
+ headers: {
222
+
223
+ 'content-type': 'application/x-www-form-urlencoded',
224
+
225
+ 'Authorization': 'Bearer ' + access_token
226
+
227
+ },
228
+
229
+ data: querystring.stringify({
230
+
231
+ photosceneid: photosceneId,
232
+
233
+ type: 'image',
234
+
235
+ 'file[0]': 'https://s3.amazonaws.com/adsk-recap-public/forge/lion/DSC_1158.JPG',
236
+
237
+ 'file[1]': 'https://s3.amazonaws.com/adsk-recap-public/forge/lion/DSC_1159.JPG',
238
+
239
+ 'file[2]': 'https://s3.amazonaws.com/adsk-recap-public/forge/lion/DSC_1160.JPG',
240
+
241
+ 'file[3]': 'https://s3.amazonaws.com/adsk-recap-public/forge/lion/DSC_1162.JPG',
242
+
243
+ 'file[4]': 'https://s3.amazonaws.com/adsk-recap-public/forge/lion/DSC_1163.JPG',
244
+
245
+ 'file[5]': 'https://s3.amazonaws.com/adsk-recap-public/forge/lion/DSC_1164.JPG',
246
+
247
+ 'file[6]': 'https://s3.amazonaws.com/adsk-recap-public/forge/lion/DSC_1165.JPG'
248
+
249
+ })
250
+
251
+ })
252
+
253
+ .then(function (response) {
254
+
255
+ // Success
256
+
257
+ console.log(response);
258
+
259
+ if (response.data.Error) {
260
+
261
+ res.send(response.data.Error.msg);
262
+
263
+ }
264
+
265
+ console.log(JSON.stringify(response.data.Files));
266
+
267
+ var nextLink = '/api/forge/recap/photoscene/process?photosceneid=' + photosceneId;
268
+
269
+ res.send('<p>Files added to photoscene!</p><a href="' + nextLink + '">Begin processing photoscene</a>');
270
+
271
+ })
272
+
273
+ .catch(function (error) {
274
+
275
+ // Failed
276
+
277
+ console.log(error);
278
+
279
+ res.send('Failed to upload files to photoscene');
280
+
281
+ });
282
+
283
+ });
284
+
143
285
  //以下略...
144
286
 
145
287
  ```
146
288
 
289
+
290
+
291
+
292
+
147
293
  ```C#
148
294
 
149
295
  //#define RECAP

1

コード表記を追加しました

2019/02/17 06:40

投稿

mypace
mypace

スコア45

test CHANGED
File without changes
test CHANGED
@@ -19,3 +19,197 @@
19
19
  渡した後に Node.jsからnpm startを実行する方法について
20
20
 
21
21
  アドバイスをいただきたく思います。
22
+
23
+
24
+
25
+ ```JavaScript
26
+
27
+ //-------------------------------------------------------------------
28
+
29
+ // These packages are included in package.json.
30
+
31
+ // Run `npm install` to install them.
32
+
33
+ // 'path' is part of Node.js and thus not inside package.json.
34
+
35
+ //-------------------------------------------------------------------
36
+
37
+ var express = require('express'); // For web server
38
+
39
+ var Axios = require('axios'); // A Promised base http client
40
+
41
+ var bodyParser = require('body-parser'); // Receive JSON format
42
+
43
+
44
+
45
+ // Set up Express web server
46
+
47
+ var app = express();
48
+
49
+ app.use(bodyParser.json());
50
+
51
+ app.use(express.static(__dirname + '/www'));
52
+
53
+
54
+
55
+ // This is for web server to start listening to port 3000
56
+
57
+ app.set('port', 3000);
58
+
59
+ var server = app.listen(app.get('port'), function () {
60
+
61
+ console.log('Server listening on port ' + server.address().port);
62
+
63
+ });
64
+
65
+
66
+
67
+ //-------------------------------------------------------------------
68
+
69
+ // Configuration for your Forge account
70
+
71
+ // Initialize the 2-legged OAuth2 client, and
72
+
73
+ // set specific scopes
74
+
75
+ //-------------------------------------------------------------------
76
+
77
+ var FORGE_CLIENT_ID = process.env.FORGE_CLIENT_ID;
78
+
79
+ var FORGE_CLIENT_SECRET = process.env.FORGE_CLIENT_SECRET;
80
+
81
+ var access_token = '';
82
+
83
+ var scopes = 'data:read data:write';
84
+
85
+ const querystring = require('querystring'); //querystring
86
+
87
+
88
+
89
+ // // Route /api/forge/oauth
90
+
91
+ app.get('/api/forge/oauth', function (req, res) {
92
+
93
+ Axios({
94
+
95
+ method: 'POST',
96
+
97
+ url: 'https://developer.api.autodesk.com/authentication/v1/authenticate',
98
+
99
+ headers: {
100
+
101
+ 'content-type': 'application/x-www-form-urlencoded',
102
+
103
+ },
104
+
105
+ data: querystring.stringify({
106
+
107
+ client_id: FORGE_CLIENT_ID,
108
+
109
+ client_secret: FORGE_CLIENT_SECRET,
110
+
111
+ grant_type: 'client_credentials',
112
+
113
+ scope: scopes
114
+
115
+ })
116
+
117
+ })
118
+
119
+ .then(function (response) {
120
+
121
+ // Success
122
+
123
+ access_token = response.data.access_token;
124
+
125
+ console.log(response);
126
+
127
+ res.send('<p>Authentication success!</p><a href="/api/forge/recap/photoscene/add">Add a photoscene</a>');
128
+
129
+ })
130
+
131
+ .catch(function (error) {
132
+
133
+ // Failed
134
+
135
+ console.log(error);
136
+
137
+ res.send('Failed to authenticate');
138
+
139
+ });
140
+
141
+ });
142
+
143
+ //以下略...
144
+
145
+ ```
146
+
147
+ ```C#
148
+
149
+ //#define RECAP
150
+
151
+ #define EDGE_JS
152
+
153
+ using System;
154
+
155
+ using System.Collections.Generic;
156
+
157
+ using System.ComponentModel;
158
+
159
+ using System.Data;
160
+
161
+ using System.Drawing;
162
+
163
+ using System.Linq;
164
+
165
+ using System.Text;
166
+
167
+ using System.Threading.Tasks;
168
+
169
+ using System.Windows.Forms;
170
+
171
+ using System.IO;
172
+
173
+ using System.Text.RegularExpressions;
174
+
175
+ using AForge.Video;
176
+
177
+ using AForge.Video.FFMPEG;
178
+
179
+ using AForge.Video.VFW;
180
+
181
+ using AForge.Video.DirectShow;
182
+
183
+ using EdgeJs;
184
+
185
+
186
+
187
+ namespace software
188
+
189
+ {
190
+
191
+ public partial class MainForm : Form
192
+
193
+ {
194
+
195
+ private void ReCapButton_Click(object sender, EventArgs e)
196
+
197
+ {
198
+
199
+ //==== 指定URLにPOST通信を行う ====//
200
+
201
+ //----- AFORGE Client ID & Client Secret -----//
202
+
203
+ string client_ID = "~~~"; //JavaScriptへの入力値
204
+
205
+ string client_Secret = "~~~";//JavaScriptへの入力値
206
+
207
+ //以下にNode.js, JavaScript操作を作成したい
208
+
209
+ }
210
+
211
+ }
212
+
213
+ }
214
+
215
+ ```