This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
chdir(__DIR__); | |
$http = new swoole_http_server('php', 8080); | |
$http->on('start', function ($server) { | |
echo "Server has been started!\n"; | |
}); | |
$http->on('request', function ($request, $response) { | |
swoole_async_readfile('index.html', function($filename, $content) use ($response) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$server = new swoole_websocket_server('php', 9501); | |
$server->on('start', function (swoole_websocket_server $server) { | |
echo "Server has been started!\n"; | |
}); | |
$server->on('open', function (swoole_websocket_server $server, $request) { | |
echo "websocket: new connection, id: {$request->fd}\n"; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$counter = 0; | |
$http = new swoole_http_server('php', 8080); | |
$http->on('request', function ($request, $response) use ($counter) { | |
$response->header("Content-Type", "text/plain"); | |
$response->end($counter++); | |
}); | |
$http->start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<application ...> | |
<!-- ... --> | |
<meta-data | |
android:name="com.google.firebase.ml.vision.DEPENDENCIES" | |
android:value="ocr" /> | |
</application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
// ... | |
implementation 'com.google.firebase:firebase-ml-vision:16.0.0' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val detector = FirebaseVision.getInstance().visionTextDetector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
detector.detectInImage(visionImage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FirebaseVisionImage.fromBitmap(textBitmap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TextDetector { | |
private val detector = FirebaseVision.getInstance().visionTextDetector | |
private val detectionOutput = PublishProcessor.create<FirebaseVisionText>() | |
private val frameInput = PublishProcessor.create<Bitmap>() | |
init { | |
frameInput.map { it.toFirebaseVisionImage() } | |
.flatMap(::detect) | |
.subscribe(detectionOutput) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val blocks = text.blocks | |
val blocksRect = blocks.mapNotNull { it.boundingBox } | |
val lines = blocks.flatMap { it.lines } | |
val linesRect = lines.mapNotNull { it.boundingBox } | |
val elements = lines.flatMap { it.elements } | |
val elementsRect = elements.mapNotNull { it.boundingBox } | |
// copy bitmap and make it mutable if necessary (optional step) |