Automatically Extracting Text with OCR from Field Captured Images

Route4Me’s OCR (optical character recognition) tool allows you to automatically extract text from uploaded images.

Description

This tool makes the route planning process faster and easier. Let’s say you have a printed sheet of contacts and addresses you need to transfer to Route4Me. If you have a lot of contacts, all that information would take a long time to type up manually.

But with our OCR tool, all you need to do is scan the sheet, and our software does the rest. The information will be transferred automatically. Piece of cake.

This tool is also helpful for when you’re out in the field. For example, when a new prospect hands you a business card, you can use it to quickly record their contact information. A business card is easy to lose – so why chance it?

Overall, you can use our OCR tool to make managing your business data much simpler.

Solution

Create an Optimization

Let’s choose the Single Driver Round Trip option for this use case. Here are the parameters for an optimization problem:

ParameterTypeDescriptionHTTP method
api_keystringAPI KEY of the userGET
redirectintegerif equal to 1, will be redirected, if 0 - notGET
addressesarrayValid JSON array of Address objects. Click here to see the JSON SchemaPOST
parametersRoute ParametersValid JSON string of RouteParameters object. Click here to see the JSON SchemaPOST

The addresses on the map will appear as below:

You can create a new optimization for this use case example. From the cUrl example bellow you can see that:

ParameterTypeDescription
api_keystringAPI KEY of the user
input dataPOST dataValid JSON object string. Click here to see the JSON Schema
1 @ECHO OFF
2 :: Single Driver Round Trip
3 
4 ::See video tutorial here: http://support.route4me.com/route-planning-help.php?id=manual0:tutorial2:chapter1:subchapter1
5 
6 SET URL=https://www.route4me.com/api.v4/optimization_problem.php
7 SET apikey=11111111111111111111111111111111
8 
9 ECHO ON
10 
11 curl -o file1.txt -g -X POST -k -d "@single_driver_round_trip_data.json" "%URL%?api_key=%apikey%"
12 
13 timeout /t 30

You can expect an Optimization problem (see link), which has generated a route already.

View Optimization Details

The endpoint: https://www.route4me.com/api.v4/optimization_problem.php

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
optimization_problem_idstringOptimization problem IDGET


1 @ECHO OFF
2 SET url=https://www.route4me.com/api.v4/optimization_problem.php
3 SET apikey=11111111111111111111111111111111
4 SET optprobid=44505E6471AB2F0DAA485BCE735EF8DC
5 
6 ECHO ON
7 curl -o file1.txt -g -X GET -k "%URL%?api_key=%apikey%&optimization_problem_id=%optprobid%"
8 
9 timeout /t 30

See sample RESPONSE JSON data here

The system will send a RESPONSE with an array of the addresses, which belongs to one round-trip route.

Details Of The Optimized Route

Details of your optimized route are available.

The endpoint: https://www.route4me.com/api.v4/route.php

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
route_idstringRoute IDGET
route_path_outputstringIf equal to 'Poitns', you'll get an array of the path points to next addressGET


1 @ECHO OFF
2 SET url=https://www.route4me.com/api.v4/route.php
3 SET apikey=11111111111111111111111111111111
4 SET routeid=D68AAF9C015D8AA4A138583453CE90EB
5 SET rpo=Points
6 SET notes=1
7 
8 ECHO ON
9 
10 curl -o file1.txt -g -k -X GET "%url%?route_id=%routeid%&api_key=%apikey%&route_path_output=%rpo%&notes=%notes%"
11 
12 timeout /t 30

See sample RESPONSE JSON data here

Note
In the RESPONSE you can see the array of the fields path_to_next. Those will be used to draw routes on a map, exactly as they are generated by the Route4Me API.

Upload An Image As A Note To An Address

You can uplod an image to a route destination as a note and Route4Me will automatically extract the text from it.

Let’s add notes to the addresses selected on the map below:

We’ll add this image with addresses on it.

The endpoint: https://www.route4me.com/actions/addRouteNotes.php

HTTP Parameters (see JSON schema here)

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
address_id intenger Address ID GET
dev_lat double Device location latitude GET
dev_lng double Device location longitude GET
strFilename string A file name to be uploaded POST
device_type string Device type. ENUM("web", "iphone", "ipad", "android_phone", "android_tablet") GET
strUpdateType string File type. ENUM("DRIVER_IMG", "VEHICLE_IMG", "ADDRESS_IMG", "CSV_FILE", "XLS_FILE", "ANY_FILE") GET


1 @ECHO OFF
2 :: Add a note to the route using of file uploading
3 
4 SET url=https://www.route4me.com/actions/addRouteNotes.php
5 SET apikey=11111111111111111111111111111111
6 SET routeid=D68AAF9C015D8AA4A138583453CE90EB
7 SET addrid=196429349
8 SET dev_lat=41.003671512008
9 SET dev_lng=-81.598461046815
10 SET dev_type=web
11 SET "filename=scanned_addresses.jpg"
12 
13 ECHO ON
14 
15 curl -o file1.txt -g -k -X POST -F "strFilename=@%filename%" "%url%?api_key=%apikey%&route_id=%routeid%&address_id=%addrid%&dev_lat=%dev_lat%&dev_lng=%dev_lng%&device_type=%dev_type%&strUpdateType=ANY_FILE"
16 
17 timeout /t 30

You’ll get this API response:

{
"status": true,
"note_id": "938657",
"upload_id": "9ad943b381fe8c46fb278c6e61fdc454",
"note": {
"note_id": 938657,
"route_id": "D68AAF9C015D8AA4A138583453CE90EB",
"route_destination_id": 196429349,
"ts_added": 1478595188,
"activity_type": "",
"upload_id": "9ad943b381fe8c46fb278c6e61fdc454",
"upload_extension": "jpg",
"upload_url": "http:\/\/adb6def9928467589ebb-f540d5a8d53c2e76ad581b6e5c346ad6.r74.cf1.rackcdn.com\/9ad943b381fe8c46fb278c6e61fdc454.jpg",
"upload_type": "ADDRESS_IMG",
"contents": "",
"lat": 41.003672,
"lng": -81.598461,
"device_type": "web"
}
}

Get Extracted Text From A Destination

You can retrieve an uploaded note and see extracted text from the custom field "OCR_Fulltext".

The endpoint: https://www.route4me.com/api.v4/address.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_destination_id intenger Route destionation ID GET
notes intenger If equal to 1, the notes will be returned in the response GET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/address.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=D68AAF9C015D8AA4A138583453CE90EB
6 SET routedestinationid=196429349
7 
8 ECHO ON
9 curl -o file1.txt -g -k -X GET "%url%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%&notes=1"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to this parameter:

"custom_fields": {
"OCR_Fulltext": "address128 Woodland Dr, Stafford, VA 225562232 Aquia Dr, Stafford, VA 2255494 The Vance Way, Fredericksburg, VA 224053 Edgewood Circle, Fredericksburg, VA 2240510700 Heatherwood Dr, Spotsylvania, VA 2255310416 Rolling Ridge Dr, Spotsylvania, VA 2255310609 Mystic Pointe Dr, Fredericksburg, VA 2240710705 Mystic Pointe Dr, Fredericksburg, VA 2240711121 Cloverdale St, Fredericksburg, VA 2240711123 Cloverdale St, Fredericksburg, VA 22407dst latdst ling38.50175476 77.5400848438.46336365 -77.3740234438.34377289 -77.3582153338.35602188 -77.4427642838.24650574 -77.5649108977.572128338.2465667738.25134277 -77.59936523-77.6008377138.2538375938.26173401 -77.6054992738.26176453 -77.60552979is depot11"
}

Upload Another Image As A Note To An Address

Let’s upload this image to a second address:

The endpoint and parameters for this are the same as they were in the previous topic Upload An Image As A Note To An Address

1 @ECHO OFF
2 :: Add a note to the route using of file uploading
3 
4 SET url=https://www.route4me.com/actions/addRouteNotes.php
5 SET apikey=11111111111111111111111111111111
6 SET routeid=D68AAF9C015D8AA4A138583453CE90EB
7 SET addrid=196429351
8 SET dev_lat=41.194505989552
9 SET dev_lng=-81.443351581693
10 SET dev_type=web
11 SET "filename=fedex_sample_shipping_label.jpg"
12 
13 ECHO ON
14 
15 curl -o file1.txt -g -k -X POST -F "strFilename=@%filename%" "%url%?api_key=%apikey%&route_id=%routeid%&address_id=%addrid%&dev_lat=%dev_lat%&dev_lng=%dev_lng%&device_type=%dev_type%&strUpdateType=ANY_FILE"
16 
17 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to this parameter:

Get Extracted Text From An Uploaded Image

The endpoint and parameters for this are the same as they were in the previous topic Get Extracted Text From A Destination.

1 @ECHO OFF
2 SET url=https://www.route4me.com/api.v4/address.php
3 SET apikey=11111111111111111111111111111111
4 SET routeid=D68AAF9C015D8AA4A138583453CE90EB
5 SET routedestinationid=196429351
6 
7 ECHO ON
8 curl -o file1.txt -g -k -X GET "%url%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%&notes=1"
9 
10 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to this parameter:

"custom_fields": {
"OCR_Fulltext": "From: MITCH GREEN (303)413-8001SHIPPER'S FEDEX ACCOUNTFedExNETSCAPE COMMUNICATIONS CORP3256 WRIGHT AVENUEBOULDER, CO, 8030To: Brent Harrison (408)276-6241iPlanet E-Commerce SolutionsSHIP DATE: 02JUL01WEIGHT1 LBSM\/S SCA22-3104220 Network CircleSanta Clara, CA, 95054Ref: 601\/895Mitch GreenDELIVERYADDRESSEARCODE FEDEX-EDRFedEx STANDARD OVERNIGHTTUETRK 7909 4164 46486e01SJCWC RBKADeliver by95054-CA-US03JUL01"
},