Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update Rotation.ml and Tools.ml

  • Loading branch information...
commit 1a8699b75604858ea7fce2718b112f539f5e2715 1 parent 6a69c4a
dezyal authored
Showing with 17 additions and 10 deletions.
  1. +10 −6 OCR/Rotation.ml
  2. +4 −1 OCR/Tools.ml
  3. +3 −3 OCR/main.ml
16 OCR/Rotation.ml
View
@@ -8,7 +8,7 @@
(* Remplissage de l'accumulateur *)
let px_vote acc acc_w acc_h x y w h rho_max =
let ox = x-w/2 and oy = y-h/2 in
- for i=0 to acc_w do
+ for i=0 to acc_w-1 do
let theta = (float)i/.(float)acc_w*.3.14159265 in
let rho = (float)ox*.cos(theta) +. (float)oy*.sin(theta) in
let i_rho = int_of_float(
@@ -42,19 +42,21 @@ let hough_skew_detection mtx w h =
let acc = Array.make_matrix theta_w rho_h 0 in
for i = 0 to w-1 do
for j = 0 to h-1 do
- px_vote acc theta_w rho_h x y w h rho_max;
+ if (mtx.(i).(j) == 0) then
+ px_vote acc theta_w rho_h i j w h rho_max;
done
done;
let (rho,theta) = winner acc theta_w rho_h rho_max in
- rhotheta2ab rho theta
+ let (a,b) = rhotheta2ab rho theta w h in
+ atan(a)
(*
[Fonction Rotate]
Effectue la rotation d'une image à partir
d'un angle en degré
*)
-let rotate mtx w h angle =
- let a = Tools.deg2rad angle in
+let rotate mtx w h a =
+ (*let a = Tools.deg2rad angle in *)
(*let new_w = int_of_float(
(float)w*.cos(a) +. (float)h*.sin(a))
and new_h = int_of_float(
@@ -67,9 +69,11 @@ let rotate mtx w h angle =
(float)x*.cos(a) -. (float)y*.sin(a))
and new_y = int_of_float(
(float)(x)*.sin(a) +. (float)y*.cos(a)) in
- print_int new_x;print_string ":";print_int new_y;print_newline();
+ (*print_int new_x;print_string ":";print_int new_y;print_newline();*)
if (new_x > -1 && new_x < w-1 && new_y > -1 && new_y < h-1) then
new_mtx.(new_x).(new_y) <- 0
done
done;
new_mtx
+
+
5 OCR/Tools.ml
View
@@ -1,10 +1,13 @@
(*
- [Fonction deg2rad]
+ [Fonctions deg2rad <-> rad2deg]
Convertie un angle en degré en radian
*)
let deg2rad d =
d*.3.14159265/.180.
+let rad2deg r =
+ r*.180./.3.14159265
+
(*
[Fonction out_of_bounds]
Renvoie true si on sort des limites du tableau
6 OCR/main.ml
View
@@ -14,9 +14,9 @@ let main () =
[|2;5;2;5;20;5;2;5;2|] (1./.48.) in
let mtx3 = Pretreatment.new_binarisation
(Pretreatment.pre_bin mtx2 w h) w h in
- let mtx3 = Rotation.rotate mtx3 w h (0.5) in
- (* let (a,b) = Rotation.hough_skew_detection mtx3 w h in
- print_int a;print_string " x + ";print_int b;*)
+ let angle = Rotation.hough_skew_detection mtx3 w h in
+ print_float (angle);print_string " degree:";
+ print_float (Tools.rad2deg angle);
OSdl.display (Pretreatment.mtx2su mtx3 w h pfi) w h;
OSdl.wait ();
exit 0
Please sign in to comment.
Something went wrong with that request. Please try again.