php と OCR を使用して画像テーブルを識別することについて、識別された画像を元の形式で完全に表示するにはどうすればよいですか?
P粉269094165
P粉269094165 2023-08-09 19:24:08
0
0
282

これは私の元のコードです:


##/**

* 投稿リクエスト

*

* @param string $url address

* @param array $headers Http Header

* @param string $body content

* @return string

*/


#function post($url, $headers, $body) {

$ch =curl_init();

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_HEADER, false);

カール_setopt($ch、CURLOPT_HTTPHEADER、$headers);

curl_setopt($ch、CURLOPT_POST、true);

curl_setopt($ch、CURLOPT_POSTFIELDS、$body);

$response =curl_exec($ch);

curl_close($ch);

return $response;

}

// ログインし、「ワークベンチ - アカウント設定 - 開発者情報」に移動して、x-ti-app-idを表示します。

// サンプル コードでは、x-ti-app - ID は実際のデータではありません

const APP_ID = '9d285d1c896';

// ログインして「ワークベンチ - アカウント設定 - 開発者情報」に移動して x-ti-secret- を表示してください。 code

//サンプルコードのx-ti-secret-codeは実際のデータではありません

const SECRET_CODE = '7be1f6203f';

//一般的なテーブル認識

const URL = 'https://api.textin.com/ai/service/v2/recognize/table';

$headers = [

' x-ti-app-id:' .APP_ID,

'x-ti-secret-code:' . SECRET_CODE

];

$ fileData = file_get_contents(' 123.png', false, stream_context_create([

'http' => [

'header' => 'Content-Type: image/png\r \n'

]

]));

$response = post(URL, $headers, $fileData);

$ocrResult = json_decode ($response, true );

function displayTable($table) {

echo "";

foreach ($table as $row) {

echo "";

foreach ($row as $cell) {

echo "";

}

## echo "

" . $cell[0]['text'] . "
;";

}

##$table = $ocrResult['result']['tables '][0]['table_cells'];

displayTable($table);


$ocrResult 多次元配列関数は正しく取得できますが、テーブルとコンテンツが元の形式で画面に表示されます

これは認識されるテーブル コンテンツの一部です:

array(5) { ["コード"]=> int(200) ["メッセージ"]=> string(7) "成功" ["期間"]=> int(289) ["結果"]=>配列(4) { ["角度"]=> int(0) ["高さ"]=> int(219) ["テーブル"]=>配列(1) { [0]=>; array(8) { ["height_of_rows"]=>配列(6) { [0]=> int(46) [1]=> int(17) [2]=> int(29) [3]=> int(32) [4]=> int(20) [5]=> int(20) } ["タイプ"]=> string(15) "table_with_line" ["table_cells"]=>配列(55) { [0]=> array(8) { ["end_row"]=> int(0) ["ボーダー"]=> array(4) { ["right"]=> int(-1) ["底"]=> int(-1) ["左"]=> int(-1) ["トップ"]=> int(-1) } ["位置"]=>配列(8) { [0]=> int(1) [1]=> int(49) [2]=> int(635) [3]=> int(49) [4]=> int(635) [5]=> int(95) [6]=> int(1) [7]=> int(95) } ["end_col"]=> int(11) ["開始行"]=> int(0) ["start_col"]=> int(0) ["行"]=>配列(1) { [0]=>;配列(7) { ["角度"]=> int(0) ["テキスト"]=> string(6) "宋体" ["方向"]=> int(1) ["手書き"]=> int(0) ["位置"]=>配列(8) { [0]=> int(7) [1]=> int(60) [2]=> int(29) [3]=> int(60) [4]=> int(29) [5]=> int(73) [6]=> int(7) [7]=> int(73) } ["スコア"]=> float(0.845) ["タイプ"]=> string(4) "テキスト" } } ["テキスト"]=> string(6) "宋体" } [1]=> array(8) { ["end_row"]=> int(1) ["ボーダー"]=> array(4) { ["right"]=> int(-1) ["底"]=> int(-1) ["左"]=> int(-1) ["トップ"]=> int(-1) } ["位置"]=>配列(8) { [0]=> int(2) [1]=> int(95) [2]=> int(26) [3]=> int(95) [4]=> int(26) [5]=> int(112) [6]=> int(2) [7]=> int(112) } ["end_col"]=> int(0) ["開始行"]=> int(1) ["start_col"]=> int(0) ["行"]=> array(0) { } ["テキスト"]=>文字列(0) "" } [2]=> array(8) { ["end_row"]=> int(1) ["ボーダー"]=> array(4) { ["right"]=> int(-1) ["底"]=> int(-1) ["左"]=> int(-1) ["トップ"]=> int(-1) } ["位置"]=>配列(8) { [0]=> int(26) [1]=> int(95) [2]=> int(84) [3]=> int(95) [4]=> int(84) [5]=> int(112) [6]=> int(26) [7]=> int(112) }["end_col"]=> int(1) ["開始行"]=> int(1) ["start_col"]=> int(1) ["行"]=>配列(1) { [0]=>;配列(7) { ["角度"]=> int(0) ["テキスト"]=> string(1) "A" ["方向"]=> int(0) ["手書き"]=> int(0) ["位置"]=>配列(8) { [0]=> int(49) [1]=> int(100) [2]=> int(61) [3]=> int(100) [4]=> int(61) [5]=> int(112) [6]=> int(49) [7]=> int(112) } ["スコア"]=> float(0.849) ["タイプ"]=> string(4) "テキスト" } } ["テキスト"]=>文字列(1) "A" } [3]=> array(8) { ["end_row"]=> int(1) ["ボーダー"]=> array(4) { ["right"]=> int(-1) ["底"]=> int(-1) ["左"]=> int(-1) ["トップ"]=> int(-1) } ["位置"]=>配列(8) { [0]=> int(84) [1]=> int(95) [2]=> int(150) [3]=> int(95) [4]=> int(150) [5]=> int(112) [6]=> int(84) [7]=> int(112) } ["end_col"]=> int(2) ["開始行"]=> int(1) ["start_col"]=> int(2) ["行"]=>配列(1) { [0]=>;配列(7) { ["角度"]=> int(0) ["テキスト"]=> string(1) "B" ["方向


P粉269094165
P粉269094165

全員に返信 (0)
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!