From: Jérémie D. <Ba...@us...> - 2011-05-28 11:05:23
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 1e3124e9a7bb03d9c9e7d2ba729a716f55d20488 (commit) via ec9cbc16966f5950708e4f6f593cf4527944940c (commit) via b7d01c1695f4e3a5c7882e53cea6ab279c9e843a (commit) via 48cd5913a78258b2b46d4f4ad5380d9285af8f96 (commit) from 5df552366b95a2043d03913e69553e04cf78bb3f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1e3124e9a7bb03d9c9e7d2ba729a716f55d20488 Author: Jérémie Dimino <je...@di...> Date: Sat May 28 13:04:37 2011 +0200 [vision] install findBallse as krobot-find-objects commit ec9cbc16966f5950708e4f6f593cf4527944940c Author: Jérémie Dimino <je...@di...> Date: Sat May 28 13:04:20 2011 +0200 [findBallse] print a separator between each frames commit b7d01c1695f4e3a5c7882e53cea6ab279c9e843a Author: Jérémie Dimino <je...@di...> Date: Sat May 28 13:03:22 2011 +0200 [info] add krobot-webcam for parsing data from the webcam analyser and remove krobot-objects commit 48cd5913a78258b2b46d4f4ad5380d9285af8f96 Author: Jérémie Dimino <je...@di...> Date: Fri May 27 20:16:53 2011 +0200 [vision] fix camfilter ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/_oasis b/info/control2011/_oasis index 90561d3..f75063a 100644 --- a/info/control2011/_oasis +++ b/info/control2011/_oasis @@ -155,11 +155,11 @@ Executable "krobot-planner" MainIs: krobot_planner.ml BuildDepends: krobot, lwt.syntax, ocamlgraph -Executable "krobot-objects" +Executable "krobot-webcam" Path: src/tools Install: true CompiledObject: best - MainIs: krobot_objects.ml + MainIs: krobot_webcam.ml BuildDepends: krobot, lwt.syntax Executable "krobot-kill" diff --git a/info/control2011/_tags b/info/control2011/_tags index bd0db84..f229535 100644 --- a/info/control2011/_tags +++ b/info/control2011/_tags @@ -2,7 +2,7 @@ <src/interfaces/*.ml>: -syntax_camlp4o # OASIS_START -# DO NOT EDIT (digest: 52f8c36639e5a9f5ad9d72f069f8491a) +# DO NOT EDIT (digest: 658e3c296fe6ed07c286a18053ad18f1) # Ignore VCS directories, you can use the same kind of rule outside # OASIS_START/STOP if you want to exclude directories that contains # useless stuff for the build process @@ -92,11 +92,11 @@ <examples/*.ml{,i}>: pkg_lwt.unix <examples/*.ml{,i}>: pkg_lwt.syntax <examples/*.ml{,i}>: pkg_lwt.react -# Executable krobot-objects -<src/tools/krobot_objects.{native,byte}>: use_krobot -<src/tools/krobot_objects.{native,byte}>: pkg_lwt.unix -<src/tools/krobot_objects.{native,byte}>: pkg_lwt.syntax -<src/tools/krobot_objects.{native,byte}>: pkg_lwt.react +# Executable krobot-webcam +<src/tools/krobot_webcam.{native,byte}>: use_krobot +<src/tools/krobot_webcam.{native,byte}>: pkg_lwt.unix +<src/tools/krobot_webcam.{native,byte}>: pkg_lwt.syntax +<src/tools/krobot_webcam.{native,byte}>: pkg_lwt.react # Executable krobot-replay <src/tools/krobot_replay.{native,byte}>: use_krobot <src/tools/krobot_replay.{native,byte}>: pkg_lwt.unix diff --git a/info/control2011/setup.ml b/info/control2011/setup.ml index d186921..1270096 100644 --- a/info/control2011/setup.ml +++ b/info/control2011/setup.ml @@ -1,7 +1,7 @@ (* setup.ml generated for the first time by OASIS v0.2.0~alpha1 *) (* OASIS_START *) -(* DO NOT EDIT (digest: b415f0d22b968b7ffae162be7c9780ab) *) +(* DO NOT EDIT (digest: 9b4431568a1901300432755d30aeb373) *) (* Regenerated by OASIS v0.2.1~alpha1 Visit http://oasis.forge.ocamlcore.org for more information and @@ -5361,7 +5361,7 @@ let setup_t = {exec_custom = false; exec_main_is = "send_can.ml"; }); Executable ({ - cs_name = "krobot-objects"; + cs_name = "krobot-webcam"; cs_data = PropList.Data.create (); cs_plugin_data = []; }, @@ -5385,8 +5385,7 @@ let setup_t = bs_byteopt = [(OASISExpr.EBool true, [])]; bs_nativeopt = [(OASISExpr.EBool true, [])]; }, - {exec_custom = false; exec_main_is = "krobot_objects.ml"; - }); + {exec_custom = false; exec_main_is = "krobot_webcam.ml"; }); Executable ({ cs_name = "krobot-replay"; diff --git a/info/control2011/src/tools/krobot_objects.ml b/info/control2011/src/tools/krobot_objects.ml deleted file mode 100644 index 0c2d681..0000000 --- a/info/control2011/src/tools/krobot_objects.ml +++ /dev/null @@ -1,115 +0,0 @@ -(* - * krobot_objects.ml - * ----------------- - * Copyright : (c) 2011, Jeremie Dimino <je...@di...> - * Licence : BSD3 - * - * This file is a part of [kro]bot. - *) - -(* Service handling the position of the objects on the board. *) - -open Lwt -open Lwt_react -open Krobot_bus -open Krobot_geom - -let section = Lwt_log.Section.make "krobot(objects)" - -(* +-----------------------------------------------------------------+ - | Types | - +-----------------------------------------------------------------+ *) - -type objects = { - bus : Krobot_bus.t; - (* The message bus used to communicate with the robot. *) - - mutable objects : vertice list; - (* The list of objects on the board. *) -} - -(* +-----------------------------------------------------------------+ - | Message handling | - +-----------------------------------------------------------------+ *) - -let handle_message objects (timestamp, message) = - match message with - | Kill "objects" -> - exit 0 - - | Send -> - ignore ( - let ts = Unix.gettimeofday () in - Krobot_bus.send objects.bus (ts, Objects objects.objects) - ) - - | _ -> - () - -(* +-----------------------------------------------------------------+ - | Command-line arguments | - +-----------------------------------------------------------------+ *) - -let fork = ref true - -let options = Arg.align [ - "-no-fork", Arg.Clear fork, " Run in foreground"; -] - -let usage = "\ -Usage: krobot-planner [options] -options are:" - -(* +-----------------------------------------------------------------+ - | Entry point | - +-----------------------------------------------------------------+ *) - -lwt () = - Arg.parse options ignore usage; - - (* Display all informative messages. *) - Lwt_log.append_rule "*" Lwt_log.Info; - - (* Open the krobot bus. *) - lwt bus = Krobot_bus.get () in - - (* Fork if not prevented. *) - if !fork then Lwt_daemon.daemonize (); - - (* Kill any running planner. *) - lwt () = Krobot_bus.send bus (Unix.gettimeofday (), Krobot_bus.Kill "objects") in - - (* Create a new planner. *) - let objects = { - bus; - objects = [ - { x = 0.800; y = 0.350 }; - { x = 1.150; y = 0.350 }; - { x = 1.850; y = 0.350 }; - { x = 2.200; y = 0.350 }; - { x = 1.500; y = 1.050 }; - { x = 0.800; y = 1.400 }; - { x = 2.200; y = 1.400 }; - { x = 1.150; y = 1.750 }; - { x = 1.850; y = 1.750 }; - { x = 0.200; y = 0.290 }; - { x = 0.200; y = 0.570 }; - { x = 0.200; y = 0.850 }; - { x = 0.200; y = 1.130 }; - { x = 0.200; y = 1.410 }; - { x = 2.800; y = 0.290 }; - { x = 2.800; y = 0.570 }; - { x = 2.800; y = 0.850 }; - { x = 2.800; y = 1.130 }; - { x = 2.800; y = 1.410 }; - ]; - } in - - (* Handle krobot message. *) - E.keep (E.map (handle_message objects) (Krobot_bus.recv bus)); - - (* Sends initial objects. *) - lwt () = Krobot_bus.send objects.bus (Unix.gettimeofday (), Objects objects.objects) in - - (* Wait forever. *) - fst (wait ()) diff --git a/info/control2011/src/tools/krobot_planner.ml b/info/control2011/src/tools/krobot_planner.ml index f980c86..32bcd4a 100644 --- a/info/control2011/src/tools/krobot_planner.ml +++ b/info/control2011/src/tools/krobot_planner.ml @@ -481,8 +481,5 @@ lwt () = (* Handle krobot message. *) E.keep (E.map (handle_message planner) (Krobot_bus.recv bus)); - (* Ask for objects. *) - lwt () = Krobot_bus.send bus (Unix.gettimeofday (), Send) in - (* Wait forever. *) fst (wait ()) diff --git a/info/control2011/src/tools/krobot_webcam.ml b/info/control2011/src/tools/krobot_webcam.ml new file mode 100644 index 0000000..b1cf643 --- /dev/null +++ b/info/control2011/src/tools/krobot_webcam.ml @@ -0,0 +1,91 @@ +(* + * krobot_webcam.ml + * ---------------- + * Copyright : (c) 2011, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(* Read webcam output and send results. *) + +open Lwt +open Lwt_react +open Krobot_bus +open Krobot_geom + +let section = Lwt_log.Section.make "krobot(webcam)" + +(* +-----------------------------------------------------------------+ + | Parsing | + +-----------------------------------------------------------------+ *) + +let rec parse bus objects ic = + (* Read one line from the object finder. *) + lwt line = Lwt_io.read_line ic in + if line = "=====" then begin + (* If it is a new frame, send current objects. *) + ignore (Krobot_bus.send bus (Unix.gettimeofday (), Objects objects)); + parse bus [] ic + end else begin + (* Otherwise read one and add it to the current list of objects. *) + let cx, cy, w, h, alpha = Scanf.sscanf line "%d %d %d %d %f" (fun cx cy w h alpha -> (cx, cy, w, h, alpha)) in + parse bus ({ x = float cx; y = float cy } :: objects) ic + end + +(* +-----------------------------------------------------------------+ + | Message handling | + +-----------------------------------------------------------------+ *) + +let handle_message bus (timestamp, message) = + match message with + | Kill "webcam" -> + exit 0 + + | _ -> + () + +(* +-----------------------------------------------------------------+ + | Command-line arguments | + +-----------------------------------------------------------------+ *) + +let fork = ref true + +let options = Arg.align [ + "-no-fork", Arg.Clear fork, " Run in foreground"; +] + +let usage = "\ +Usage: krobot-webcam [options] +options are:" + +(* +-----------------------------------------------------------------+ + | Entry point | + +-----------------------------------------------------------------+ *) + +lwt () = + Arg.parse options ignore usage; + + (* Display all informative messages. *) + Lwt_log.append_rule "*" Lwt_log.Info; + + (* Open the krobot bus. *) + lwt bus = Krobot_bus.get () in + + (* Fork if not prevented. *) + if !fork then Lwt_daemon.daemonize (); + + (* Kill any running webcam handler. *) + lwt () = Krobot_bus.send bus (Unix.gettimeofday (), Krobot_bus.Kill "webcam") in + + (* Handle krobot message. *) + E.keep (E.map (handle_message bus) (Krobot_bus.recv bus)); + + (* Launch the objects finder. *) + let process = Lwt_process.open_process_in ("krobot-find-objects", [|"krobot-find-objects"|]) in + + (* Read the first separator. *) + lwt _ = Lwt_io.read_line process#stdout in + + (* Parse forever. *) + parse bus [] process#stdout diff --git a/info/vision/coupe2011/Makefile b/info/vision/coupe2011/Makefile index 838279c..15ccf16 100644 --- a/info/vision/coupe2011/Makefile +++ b/info/vision/coupe2011/Makefile @@ -2,8 +2,12 @@ OBJECTS = camfilter capture capturevideo findBallse fiteellipse_cam fiteellipse_ CC = g++ CFLAGS = -ggdb `pkg-config --cflags opencv` LDFLAGS = `pkg-config --libs opencv` +PREFIX = $(HOME) all: $(OBJECTS) clean: rm -f $(OBJECTS) + +install: + install -m 0755 findBallse $(PREFIX)/bin/krobot-find-objects diff --git a/info/vision/coupe2011/camfilter.c b/info/vision/coupe2011/camfilter.c index f90c95f..d2077f3 100644 --- a/info/vision/coupe2011/camfilter.c +++ b/info/vision/coupe2011/camfilter.c @@ -261,7 +261,6 @@ void process_image(int h) } // Free memory. - free(imCont->roi); imCont->roi = NULL; free(PointArray); free(PointArray2D32f); free(box); @@ -269,6 +268,7 @@ void process_image(int h) } // On libère la mémoire + free(imCont->roi); imCont->roi = NULL; cvReleaseMemStorage(&stor); cvReleaseImage(&image02); } diff --git a/info/vision/coupe2011/findBallse.c b/info/vision/coupe2011/findBallse.c index 8c98664..d5abdb9 100644 --- a/info/vision/coupe2011/findBallse.c +++ b/info/vision/coupe2011/findBallse.c @@ -159,6 +159,9 @@ void process_image() stor = cvCreateMemStorage(0); cont = cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvSeq), sizeof(CvPoint) , stor); + /* Print a separator. */ + printf("====="); + if (cont) { // Threshold the source image. This needful for cvFindContours(). cvThreshold( image03, image02, params.threshold, 255, CV_THRESH_BINARY ); hooks/post-receive -- krobot |