▒█▀▀█ █▀▀ █░░█ ▒█▀▀█ █░░█ ░▀░ █▀▀█
▒█▄▄█ ▀▀█ █▄▄█ ▒█░░░ █▀▀█ ▀█▀ █░░█
▒█░░░ ▀▀▀ ▄▄▄█ ▒█▄▄█ ▀░░▀ ▀▀▀ █▀▀▀
Simple object detection with php. designed for extracting hashtags from nike rvsp images.<?php /* * Nike RVSP text extractor * Armagan Corlu aka Psy_chip * May 2013 * * root@psychip.net * */ function GetTextFromImage($filename, $saveto) { // working area dimensions $xlimit = 375; $ylimit = 200; $im = imagecreatefromjpeg($filename); $black = imagecolorallocate($im, 0, 0, 0); $green = imagecolorallocate($im, 0, 255, 0); // make image more readable imagefilter($im, IMG_FILTER_BRIGHTNESS, -80); imagefilter($im, IMG_FILTER_CONTRAST, -250); imagefilter($im, IMG_FILTER_COLORIZE, -255, 0, -255, 0); // fill areas outside the radius for ($x = 0; $x < $ylimit; $x++) { for ($i = 0; $i < $xlimit; $i++) { $rgb = imagecolorat($im, $i, $x); $color = imagecolorsforindex($im, $rgb); if ($color['green'] > 220) { if ($i < 50) imagefill($im, $i, $x, $black); } } } // Remove Noise for ($x = 0; $x < $ylimit; $x++) { for ($i = 0; $i < $xlimit; $i++) { $rgb = imagecolorat($im, $i, $x); $color = imagecolorsforindex($im, $rgb); if ($color['green'] < 255) { imagefill($im, $i, $x, $black); } } } // safety shot imagefill($im, 1, 1, $green); // detect empty areas $maincolor = imagecolorat($im, 1, 1); $b_top = 0; $b_btm = 0; $b_lft = 0; $b_rt = 0; $newimg = imagecreatetruecolor(imagesx($im), $ylimit); imagecopy($newimg, $im, 0, 0, 0, 0, imagesx($newimg), $ylimit); $im = $newimg; for (; $b_top < imagesy($im); ++$b_top) { for ($x = 0; $x < imagesx($im); ++$x) { if (imagecolorat($im, $x, $b_top) != $maincolor) { break 2; } } } for (; $b_btm < imagesy($im); ++$b_btm) { for ($x = 0; $x < imagesx($im); ++$x) { if (imagecolorat($im, $x, imagesy($im) - $b_btm - 1) != $maincolor) { break 2; } } } for (; $b_lft < imagesx($im); ++$b_lft) { for ($y = 0; $y < imagesy($im); ++$y) { if (imagecolorat($im, $b_lft, $y) != $maincolor) { break 2; } } } for (; $b_rt < imagesx($im); ++$b_rt) { for ($y = 0; $y < imagesy($im); ++$y) { if (imagecolorat($im, imagesx($im) - $b_rt - 1, $y) != $maincolor) { break 2; } } } // crop image $newimg = imagecreatetruecolor(imagesx($im) - ($b_lft + $b_rt), imagesy($im) - ($b_top + $b_btm)); imagefill($newimg, 1, 1, $green); imagecopy($newimg, $im, 0, 0, $b_lft, $b_top, imagesx($newimg), imagesy($newimg)); // tesseract OCR needs a difference for recognize text, enlarge image a bit $border = imagecreatetruecolor(imagesx($newimg) + 10, imagesy($newimg) + 10); imagefill($border, 1, 1, $green); imagecopy($border, $newimg, 5, 5, 0, 0, imagesx($newimg), imagesy($newimg)); imagepng($border, $saveto); } ?>
libraspi.js
3 Year, 1 Month ago
wifi_sensor_station.ino
serialrelay.ino
sensorstation.ino
class.dbipc.php