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-03 20:01:28 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
aa0ec6ca5da9748ce9d18aadc1cf815a39ca487b
aa0ec6ca
1 parent
65348907
Update app.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
app.js
app.js
View file @
aa0ec6c
...
...
@@ -64,19 +64,29 @@ const client = new line.Client(config);
const
vision
=
require
(
'@google-cloud/vision'
);
// Creates a client
const
visionclient
=
new
vision
.
ImageAnnotatorClient
(
);
var
vision
=
require
(
'google-vision-api-client'
);
/**
* TODO(developer): Uncomment the following line before running the sample.
*/
// const fileName = 'Local image file, e.g. /path/to/image.png';
var
requtil
=
vision
.
requtil
;
// Performs text detection on the local file
const
[
result
]
=
visionclient
.
textDetection
(
'/home/ubuntu/a/LINEBOT/photo/Fancy-TWICE.jpg'
);
const
detections
=
result
.
textAnnotations
;
console
.
log
(
'Text:'
);
detections
.
forEach
(
text
=>
console
.
log
(
text
));
//Prepare your service account from trust preview certificated project
var
jsonfile
=
'/Users/terry/dev/ws/nodejs/GoogleVisionAPISample/My Project-eee0a2d4532a.json'
;
//Initialize the api
vision
.
init
(
jsonfile
);
//Build the request payloads
var
d
=
requtil
.
createRequests
().
addRequest
(
requtil
.
createRequest
(
'/Users/terry/images/dale2.jpg'
)
.
withFeature
(
'Optical Character Recognition'
,
3
)
.
build
());
//Do query to the api server
vision
.
query
(
d
,
function
(
e
,
r
,
d
){
if
(
e
)
console
.
log
(
'ERROR:'
,
e
);
...
...
@@ -85,6 +95,9 @@ if(e) console.log('ERROR:', e);
app
.
post
(
'/webhook'
,
line
.
middleware
(
config
),
(
req
,
res
)
=>
{
Promise
.
all
(
req
.
body
.
events
.
map
(
handleEvent
))
...
...
Please
register
or
login
to post a comment