Played with some image processing functions, get some rough procedure.
Import the test image:
img = Import["https://i.sstatic.net/H2Ksg.jpg"];
Do some gamma adjust to emphasize the edge:
img // ImageAdjust[#, {0, 0, 5}] &;
Draw rough edges:
GradientFilter[%, 2, "NonMaxSuppression" -> True] // ImageAdjust
Binarize and dilate it to form connected edges:
% // MorphologicalBinarize[#, {.1, .1}] & // Dilation[#, 1] &
Draw edges which are straight and long enough:
% // DeleteSmallComponents[#, 3200] &
EdgeDetect[%, 1, .1, "StraightEdges" -> 0.2] // DeleteSmallComponents[#, 300] &
Detect lines:
lines = ImageLines[%];
Show[img, Graphics[{Thick, Orange, Line /@ lines}]]
Extract corners of the card:
lineEqs = Cross[Append[{x, y} - #1, 0], Append[#2 - #1, 0]][[3]] & @@ # & /@ lines
corners = Select[
{x, y} /. Solve[Thread[# == 0], {x, y}][[1]] & /@
Subsets[lineEqs, {2}],
Norm[#] < 2000 &]
{{258.935, 624.228}, {904.807, 376.208}, {75.9044, 279.788}, {739.114, 5.80901}}
Extract the information piece:
correctedimg = With[{w = 900, h = 500},
transfunc =
FindGeometricTransform[{{0, h}, {w, h}, {0, 0}, {w, 0}}, corners][[
2]];
ImageCrop[
ImagePerspectiveTransformation[img, transfunc,
DataRange -> Full], {w, h}, Top]
]
infoPiece =
ImageAdjust[
ImageCrop[
ImageCrop[correctedimg, {420, 260}, {Left, Center}], {350, Full},
Right], {5, .1, 1.2}]
Finally, do some OCR:
TextRecognize[infoPiece]
"TRAVIS HOWELL
Graphic + Web Designer
Q 1 23 456 7890
Q trvshowe!|@gmail.com
? www.TravisHD.com"
Conclusion
Though the image processing procedure is very rough, the outcome image could be thought as fair good (at least true for specialised OCR software). So the left work, like Tom said in comment, seems to be about how to make TextRecognize
working better.