Toggle navigation
Toggle navigation
This project
Loading...
Sign in
은승우
/
LINEBOT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
은승우
2019-12-04 19:42:27 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
99b477e50e57d0fec1810dd562ae44ae9b987471
99b477e5
1 parent
97a61655
ocr test
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
get.js
get.js
0 → 100644
View file @
99b477e
'use strict'
;
const
request
=
require
(
'request'
);
let
subscriptionKey
=
process
.
env
[
'COMPUTER_VISION_SUBSCRIPTION_KEY'
];
let
endpoint
=
process
.
env
[
'COMPUTER_VISION_ENDPOINT'
]
if
(
!
subscriptionKey
)
{
throw
new
Error
(
'Set your environment variables for your subscription key and endpoint.'
);
}
var
uriBase
=
endpoint
+
'vision/v2.1/ocr'
;
const
imageUrl
=
'https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/'
+
'Atomist_quote_from_Democritus.png/338px-Atomist_quote_from_Democritus.png'
;
// Request parameters.
const
params
=
{
'language'
:
'unk'
,
'detectOrientation'
:
'true'
,
};
const
options
=
{
uri
:
uriBase
,
qs
:
params
,
body
:
'{"url": '
+
'"'
+
imageUrl
+
'"}'
,
headers
:
{
'Content-Type'
:
'application/json'
,
'Ocp-Apim-Subscription-Key'
:
subscriptionKey
}
};
request
.
post
(
options
,
(
error
,
response
,
body
)
=>
{
if
(
error
)
{
console
.
log
(
'Error: '
,
error
);
return
;
}
let
jsonResponse
=
JSON
.
stringify
(
JSON
.
parse
(
body
),
null
,
' '
);
console
.
log
(
'JSON Response\n'
);
console
.
log
(
jsonResponse
);
});
\ No newline at end of file
Please
register
or
login
to post a comment