ScoreSight is a powerful real-time OCR application for scoreboards, videos and games
ScoreSight now offers the ability to send OCR-extracted scoreboard data to external APIs. This tutorial will guide you through setting up the feature and provide a simple Python script to receive the data.
If you encounter issues with the API integration, follow these steps to troubleshoot:
nnnn-nn-nn 10:59:14,743 - ERROR - api_output - Error sending data to output API: http://localahost:8091, HTTPConnectionPool(host='localahost', port=8091): Max retries exceeded with url: / (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x0000019089C20DA0>: Failed to resolve 'localahost' ([Errno 11001] getaddrinfo failed)"))
http://localhost:8091
for local testing).If problems persist after trying these steps, consider reaching out to ScoreSight support for further assistance.
Here’s a simple Python script that sets up a local server to receive HTTP requests from ScoreSight:
from http.server import HTTPServer, BaseHTTPRequestHandler
import json
class RequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
self.handle_request()
def do_PUT(self):
self.handle_request()
def do_GET(self):
self.handle_request()
def handle_request(self):
if self.command in ['POST', 'PUT']:
content_length = int(self.headers['Content-Length'])
post_data = self.rfile.read(content_length)
print(f"Received {self.command} data:")
try:
# Assuming JSON format, adjust if using XML or CSV
data = json.loads(post_data.decode('utf-8'))
print(json.dumps(data, indent=2))
except json.JSONDecodeError:
print(post_data.decode('utf-8'))
elif self.command == 'GET':
print("Received GET request")
print(f"Path: {self.path}")
print(f"Headers: {self.headers}")
self.send_response(200)
self.end_headers()
self.wfile.write(b'OK')
def run_server(port=8091):
server_address = ('', port)
httpd = HTTPServer(server_address, RequestHandler)
print(f"Server running on port {port}")
httpd.serve_forever()
if __name__ == '__main__':
run_server()
To run the script:
scoresight_receiver.py
python scoresight_receiver.py
The server will start and listen for incoming requests on http://localhost:8091
. Make sure to use this URL in ScoreSight’s API settings.
When ScoreSight sends data, the script will print it to the console. You can modify the script to process or store the data as needed.
You may see in the console an output similar to:
127.0.0.1 - - [nn/nn/nnnn 10:57:03] "POST / HTTP/1.1" 200 -
Received POST data: Name,Text,State,X,Y,Width,Height
Time,0:52,SameNoChange,843.656319861826,663.0215827338131,359.13669064748206,207.19424460431662
Home Score,35,SameNoChange,525.969716884406,638.4370727628325,214.62426933453253,175.27648662320166
Remember to adjust the script if you’re using XML or CSV encoding instead of JSON.
Check the console where it’s running for any error messages or unexpected output.