Permalink
Browse files

Create ocr_gui.ml

  • Loading branch information...
1 parent 8477b48 commit da43aecc97da09212574d5fdf52a55e48fe20794 @CercleOnix committed Dec 9, 2012
Showing with 127 additions and 0 deletions.
  1. +127 −0 ocr_gui.ml
View
@@ -0,0 +1,127 @@
+let _ = GMain.init()
+
+(* Fenêtre principale de l'application. *)
+let window = GWindow.window
+ ~title:"Colibri"
+ ~position:`CENTER
+ ~height:600
+ ~width:800 ()
+
+let box = GPack.vbox
+ ~spacing:2
+ ~border_width:10
+ ~packing:window#add ()
+
+(* Toolbar *)
+let toolbar = GButton.toolbar
+ ~orientation:`HORIZONTAL
+ ~style:`ICONS
+ ~packing:(box#pack ~expand:false) ()
+
+(* Parcourir *)
+let btn = GFile.chooser_button
+ ~action:`OPEN
+ ~packing:(box#pack ~expand:false) ()
+
+let get_contents = function (* str_op -> str *)
+ | Some x -> x
+ | _ -> raise Not_found
+
+
+let data = [`T "Extraire le texte"; `S; `B `SAVE; `S; `B `CUT; `B `COPY; `B `PASTE; `S;]
+
+let btn1 = GButton.tool_button
+ ~label:"Extraire le texte"
+ ~packing:toolbar#insert ()
+
+let save = GButton.tool_button
+ ~stock:`SAVE
+ ~packing:toolbar#insert ()
+
+let _ =
+ let packing = toolbar#insert in
+ List.iter (function
+ | `S -> ignore (GButton.separator_tool_item ~packing ())
+ | `B stock -> ignore (GButton.tool_button ~stock ~packing ())
+ | _ -> ()
+ ) data
+
+let _ =
+ begin
+ ignore ibtn1#connect#clicked
+(function _ -> Main.main (get_contents (btn#filename)))
+ end
+
+let item = GButton.tool_item
+ ~packing:toolbar#insert ()
+
+let about_button =
+ let dlg = GWindow.about_dialog
+ ~authors:
+ ["Les Greens :
+
+Abisaad Elie (<abisaa_e@epita.fr>)
+Dos Santos Johan (<dossan_j@epita.fr>)
+Froger Antoine (<froger_a@epita.fr>)
+Gibert Charles (<gibert_c@epita.fr>)"]
+ ~copyright:"Copyright © 2012-2013 Colibri"
+ ~version:" version 1.0"
+ ~website:"site elie ici"
+ ~position:`CENTER_ON_PARENT
+ ~parent:window
+ ~destroy_with_parent:true () in
+ let btn = GButton.button ~stock:`ABOUT ~packing:item#add () in
+ GMisc.image ~stock:`ABOUT ~packing:btn#set_image ();
+ btn#connect#clicked (fun () -> ignore (dlg#run ()); dlg#misc#hide ());
+ btn
+
+(* Boutons presentation *)
+let bbox = GPack.button_box `HORIZONTAL
+ ~layout:`EDGE
+ ~packing:box#pack ()
+
+let binarisation = GButton.button ~label:"binarisation" ~packing:bbox#add ()
+let rotation = GButton.button ~label:"rotation" ~packing:bbox#add ()
+let rlsa = GButton.button ~label:"rlsa" ~packing:bbox#add ()
+let extraction = GButton.button ~label:"extraction" ~packing:bbox#add ()
+
+
+(* Textbox *)
+let txt_frame = GBin.aspect_frame
+ ~label:"Texte"
+ ~packing:box#add ()
+let entry = GEdit.entry
+ ~text: ""
+ ~height:500
+ ~packing: txt_frame#add
+ ()
+
+let scrolltext = GRange.scrollbar `VERTICAL
+ ~packing:texte_frame#add ()
+
+(* Image Preview *)
+let img_frame = GBin.aspect_frame
+ ~label:"Image"
+ ~packing:box#add ()
+
+let image = GMisc.image
+ ~packing:img_frame#add ()
+
+(* Events *)
+
+let _ =
+ save#connect#clicked (fun _ -> let stg = entry#get_text in(* fonction de sauvegarde ici *))
+ binarisation#connect#clicked (fun _ -> image#set_file "bin.bmp");
+ rotation#connect#clicked (fun _ -> image#set_file "rot.bmp");
+ rlsa#connect#clicked (fun _ -> image#set_file "rlsa.bmp");
+ extraction#connect#clicked (fun _ -> image#set_file "extraction.bmp")
+
+let _ =
+ btn#connect#selection_changed ~callback:(
+ fun _ -> image#set_file(get_contents btn#filename);
+ entry#set_text("Texte extrait à partir de l'image.")
+ );
+ window#connect#destroy ~callback:GMain.quit;
+
+ window#show();
+ GMain.main()

0 comments on commit da43aec

Please sign in to comment.