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:16:15 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
97a616555b3d27a5da9f318084aeacfe1c0a23d2
97a61655
1 parent
50bfde6d
test ocr
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
get-printed-text.js
get-printed-text.js
0 → 100644
View file @
97a6165
'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