From eaec1671d6e01052e1627057080838240becf798 Mon Sep 17 00:00:00 2001 From: clinton Date: Fri, 7 Apr 2017 09:48:04 +1000 Subject: [PATCH] [#142565807] - Added filter for objects larger than an area specified in pixels. --- README.md | 2 +- controllers/scout_test.go | 8 ++--- frontend/src/components/settings.jsx | 7 ++++ main.go | 2 +- .../0013_add_max_area_to_scouts.down.sql | 1 + migrations/0013_add_max_area_to_scouts.up.sql | 1 + models/ScoutInteraction_test.go | 32 +++++++++---------- models/ScoutSummary_test.go | 8 ++--- models/scout.go | 27 +++++++++------- models/scoutHealth_test.go | 6 ++-- models/scoutLog_test.go | 4 +-- models/scout_test.go | 10 +++--- processes/monitor.go | 4 +-- processes/summarise_test.go | 6 ++-- 14 files changed, 65 insertions(+), 53 deletions(-) create mode 100644 migrations/0013_add_max_area_to_scouts.down.sql create mode 100644 migrations/0013_add_max_area_to_scouts.up.sql diff --git a/README.md b/README.md index 21de576..766371f 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ Visit localhost:1323 in your browser. ## Testing for the backend: ``` - $ go test -p 1 github.com/MeasureTheFuture/mothership/... + $ go test -p 1 github.com/MeasureTheFuture/scout/... ``` ## License diff --git a/controllers/scout_test.go b/controllers/scout_test.go index aa87e28..c3f5c49 100644 --- a/controllers/scout_test.go +++ b/controllers/scout_test.go @@ -94,13 +94,13 @@ var _ = Describe("Scout controller", func() { It("should return a list of all the attached scouts", func() { s := models.Scout{"59ef7180-f6b2-4129-99bf-970eb4312b4b", "192.168.0.1", 8080, true, "foo", "calibrating", &models.ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) s2 := models.Scout{"eeef7180-f6b2-4129-99bf-970eb4312b4b", "192.168.0.2", 8080, true, "foop", "calibrating", &models.ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err = s2.Insert(db) Ω(err).Should(BeNil()) @@ -126,7 +126,7 @@ var _ = Describe("Scout controller", func() { It("should return a single scout", func() { s := models.Scout{"59ef7180-f6b2-4129-99bf-970eb4312b4b", "192.168.0.1", 8080, true, "foo", "calibrated", &models.ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -152,7 +152,7 @@ var _ = Describe("Scout controller", func() { It("should be able to update a single scout", func() { s := models.Scout{"59ef7180-f6b2-4129-99bf-970eb4312b4b", "192.168.0.1", 8080, true, "foo", "calibrated", &models.ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) diff --git a/frontend/src/components/settings.jsx b/frontend/src/components/settings.jsx index d99204a..b6c46c2 100644 --- a/frontend/src/components/settings.jsx +++ b/frontend/src/components/settings.jsx @@ -36,6 +36,7 @@ var Settings = React.createClass({ var state = store.getState(); this.updateField("MinArea"); + this.updateField("MaxArea"); this.updateField("MinDuration"); this.updateField("IdleDuration"); this.updateField("MogHistoryLength"); @@ -66,6 +67,12 @@ var Settings = React.createClass({ The minimum area (in pixels) of a detected object before it gets counted as a person. +
+ + + The maximum area (in pixels) of a detected object before it gets counted as a person. +
+
diff --git a/main.go b/main.go index 4464fb4..a0a9be9 100644 --- a/main.go +++ b/main.go @@ -83,7 +83,7 @@ func main() { } if c == 0 { ns := models.Scout{"", "0.0.0.0", 8080, false, "Location " + strconv.FormatInt(c+1, 10), "idle", &models.ScoutSummary{}, - 6160.0, 10, 128, 5, 500, 30.0, 0, 5.0, 2.0, 1.0, 200} + 6160.0, 10, 128, 5, 500, 30.0, 0, 5.0, 2.0, 1.0, 200, 115000.0} err = ns.Insert(db) if err != nil { log.Fatalf("ERROR: Unable to add initial scout to DB.") diff --git a/migrations/0013_add_max_area_to_scouts.down.sql b/migrations/0013_add_max_area_to_scouts.down.sql new file mode 100644 index 0000000..c7b915a --- /dev/null +++ b/migrations/0013_add_max_area_to_scouts.down.sql @@ -0,0 +1 @@ +ALTER TABLE scouts DROP COLUMN max_area; \ No newline at end of file diff --git a/migrations/0013_add_max_area_to_scouts.up.sql b/migrations/0013_add_max_area_to_scouts.up.sql new file mode 100644 index 0000000..5c98008 --- /dev/null +++ b/migrations/0013_add_max_area_to_scouts.up.sql @@ -0,0 +1 @@ +ALTER TABLE scouts ADD COLUMN max_area double precision NOT NULL DEFAULT 2.0; \ No newline at end of file diff --git a/models/ScoutInteraction_test.go b/models/ScoutInteraction_test.go index a8b7352..1e8e2d1 100644 --- a/models/ScoutInteraction_test.go +++ b/models/ScoutInteraction_test.go @@ -40,7 +40,7 @@ var _ = Describe("Scout Interaction Model", func() { wp := []Waypoint{Waypoint{1, 2, 3, 4, 0.1}} s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) i := Interaction{"abc", "0.1", t, t, 0.1, wp, 1, &s} @@ -58,7 +58,7 @@ var _ = Describe("Scout Interaction Model", func() { Context("Get", func() { It("should be able to get scout interactions as json", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -83,7 +83,7 @@ var _ = Describe("Scout Interaction Model", func() { Context("Insert", func() { It("Should be able to insert a scout interaction", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -101,7 +101,7 @@ var _ = Describe("Scout Interaction Model", func() { Context("Delete", func() { It("Should be able to delete interactions for a specified scout", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -125,7 +125,7 @@ var _ = Describe("Scout Interaction Model", func() { Context("Unprocessed", func() { It("Should be able to get unproccessed interactions", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -151,7 +151,7 @@ var _ = Describe("Scout Interaction Model", func() { Context("MarkProcessed", func() { It("Should be able to mark interactions as processed", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -173,7 +173,7 @@ var _ = Describe("Scout Interaction Model", func() { Context("Init scene", func() { It("should be able to init an empty scene", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) si := InitScene(&s) @@ -236,7 +236,7 @@ var _ = Describe("Scout Interaction Model", func() { tr := time.Now().UTC().Round(15 * time.Minute) s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -253,7 +253,7 @@ var _ = Describe("Scout Interaction Model", func() { b := Waypoint{1, 1, 1, 1, 0.005} s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -275,7 +275,7 @@ var _ = Describe("Scout Interaction Model", func() { It("should be able to add an interaction to an empty scene", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -288,7 +288,7 @@ var _ = Describe("Scout Interaction Model", func() { It("should be able to add multiple interactions to an empty scene,", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -302,7 +302,7 @@ var _ = Describe("Scout Interaction Model", func() { It("should list the interaction start time truncated to 30 mins", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -314,7 +314,7 @@ var _ = Describe("Scout Interaction Model", func() { It("should be able to add an interaction to a scene with stuff already going on", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -331,7 +331,7 @@ var _ = Describe("Scout Interaction Model", func() { It("should be able to add multiple interactions to a scene with stuff already going on", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -348,7 +348,7 @@ var _ = Describe("Scout Interaction Model", func() { It("should be able to remove interactions when a person leaves the scene", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -362,7 +362,7 @@ var _ = Describe("Scout Interaction Model", func() { It("should be able to remove multiple interactions when more than one person leaves the scene", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) diff --git a/models/ScoutSummary_test.go b/models/ScoutSummary_test.go index 6fd6282..d6d6f4e 100644 --- a/models/ScoutSummary_test.go +++ b/models/ScoutSummary_test.go @@ -36,7 +36,7 @@ var _ = Describe("Scout Summary Model", func() { Context("Insert", func() { It("Scout insert should create matching scout summary", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -47,7 +47,7 @@ var _ = Describe("Scout Summary Model", func() { It("Should be able to update existing scout summary.", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -69,7 +69,7 @@ var _ = Describe("Scout Summary Model", func() { It("should be able to get scout healths as json", func() { ss := ScoutSummary{} s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ss, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) ss.ScoutUUID = s.UUID Ω(err).Should(BeNil()) @@ -90,7 +90,7 @@ var _ = Describe("Scout Summary Model", func() { Context("Clear", func() { It("Should be able to clear an existing scout summary", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) diff --git a/models/scout.go b/models/scout.go index 5c4c2bc..ccd0ca4 100644 --- a/models/scout.go +++ b/models/scout.go @@ -71,20 +71,21 @@ type Scout struct { MinDuration float32 IdleDuration float32 ResumeSqDistance int64 + MaxArea float64 } func GetScoutByUUID(db *sql.DB, uuid string) (*Scout, error) { const query = `SELECT ip_address, port, authorised, name, state, min_area, dilation_iterations, foreground_thresh, guassian_smooth, mog_history_length, mog_threshold, mog_detect_shadows, - simplify_epsilon, min_duration, idle_duration, resume_sq_distance + simplify_epsilon, min_duration, idle_duration, resume_sq_distance, max_area FROM scouts WHERE uuid = $1` var result Scout err := db.QueryRow(query, uuid).Scan(&result.IpAddress, &result.Port, &result.Authorised, &result.Name, &result.State, &result.MinArea, &result.DilationIterations, &result.ForegroundThresh, &result.GaussianSmooth, &result.MogHistoryLength, &result.MogThreshold, &result.MogDetectShadows, &result.SimplifyEpsilon, - &result.MinDuration, &result.IdleDuration, &result.ResumeSqDistance) + &result.MinDuration, &result.IdleDuration, &result.ResumeSqDistance, &result.MaxArea) result.UUID = uuid result.Summary, err = GetScoutSummaryByUUID(db, result.UUID) if err != nil { @@ -98,14 +99,14 @@ func GetScout(db *sql.DB) *Scout { const query = `SELECT uuid, ip_address, port, authorised, name, state, min_area, dilation_iterations, foreground_thresh, guassian_smooth, mog_history_length, mog_threshold, mog_detect_shadows, - simplify_epsilon, min_duration, idle_duration, resume_sq_distance + simplify_epsilon, min_duration, idle_duration, resume_sq_distance, max_area FROM scouts LIMIT 1` var result Scout err := db.QueryRow(query).Scan(&result.UUID, &result.IpAddress, &result.Port, &result.Authorised, &result.Name, &result.State, &result.MinArea, &result.DilationIterations, &result.ForegroundThresh, &result.GaussianSmooth, &result.MogHistoryLength, &result.MogThreshold, &result.MogDetectShadows, &result.SimplifyEpsilon, - &result.MinDuration, &result.IdleDuration, &result.ResumeSqDistance) + &result.MinDuration, &result.IdleDuration, &result.ResumeSqDistance, &result.MaxArea) if err != nil { log.Fatalf("Unable to get scout %v", err) } @@ -128,7 +129,8 @@ func GetAllScouts(db *sql.DB) ([]*Scout, error) { const query = `SELECT uuid, ip_address, port, authorised, name, state, min_area, dilation_iterations, foreground_thresh, guassian_smooth, mog_history_length, mog_threshold, mog_detect_shadows, - simplify_epsilon, min_duration, idle_duration, resume_sq_distance FROM scouts` + simplify_epsilon, min_duration, idle_duration, resume_sq_distance, + max_area FROM scouts` var result []*Scout rows, err := db.Query(query) @@ -145,7 +147,7 @@ func GetAllScouts(db *sql.DB) ([]*Scout, error) { &s.MinArea, &s.DilationIterations, &s.ForegroundThresh, &s.GaussianSmooth, &s.MogHistoryLength, &s.MogThreshold, &s.MogDetectShadows, &s.SimplifyEpsilon, &s.MinDuration, - &s.IdleDuration, &s.ResumeSqDistance) + &s.IdleDuration, &s.ResumeSqDistance, &s.MaxArea) if err != nil { return result, err } @@ -192,13 +194,13 @@ func (s *Scout) Insert(db *sql.DB) error { const query = `INSERT INTO scouts (ip_address, port, authorised, name, state, min_area, dilation_iterations, foreground_thresh, guassian_smooth, mog_history_length, mog_threshold, mog_detect_shadows, - simplify_epsilon, min_duration, idle_duration, resume_sq_distance) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) RETURNING uuid` + simplify_epsilon, min_duration, idle_duration, resume_sq_distance, max_area) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17) RETURNING uuid` err := db.QueryRow(query, s.IpAddress, s.Port, s.Authorised, s.Name, s.State, s.MinArea, s.DilationIterations, s.ForegroundThresh, s.GaussianSmooth, s.MogHistoryLength, s.MogThreshold, s.MogDetectShadows, s.SimplifyEpsilon, s.MinDuration, - s.IdleDuration, s.ResumeSqDistance).Scan(&s.UUID) + s.IdleDuration, s.ResumeSqDistance, s.MaxArea).Scan(&s.UUID) if err != nil { return err } @@ -213,12 +215,13 @@ func (s *Scout) Update(db *sql.DB) error { state = $5, min_area = $6, dilation_iterations = $7, foreground_thresh = $8, guassian_smooth = $9, mog_history_length = $10, mog_threshold = $11, mog_detect_shadows = $12, simplify_epsilon = $13, - min_duration = $14, idle_duration = $15, resume_sq_distance = $16 WHERE uuid = $17` + min_duration = $14, idle_duration = $15, resume_sq_distance = $16, + max_area = $17 WHERE uuid = $18` _, err := db.Exec(query, s.IpAddress, s.Port, s.Authorised, s.Name, s.State, s.MinArea, s.DilationIterations, s.ForegroundThresh, s.GaussianSmooth, s.MogHistoryLength, s.MogThreshold, s.MogDetectShadows, s.SimplifyEpsilon, s.MinDuration, - s.IdleDuration, s.ResumeSqDistance, s.UUID) + s.IdleDuration, s.ResumeSqDistance, s.MaxArea, s.UUID) return err } @@ -243,7 +246,7 @@ func ScoutsAsJSON(db *sql.DB) ([]string, error) { err = rows.Scan(&s.UUID, &s.IpAddress, &s.Authorised, &image, &s.Name, &s.State, &s.Port, &s.MinArea, &s.DilationIterations, &s.ForegroundThresh, &s.GaussianSmooth, &s.MogHistoryLength, &s.MogThreshold, &s.MogDetectShadows, &s.SimplifyEpsilon, - &s.MinDuration, &s.IdleDuration, &s.ResumeSqDistance) + &s.MinDuration, &s.IdleDuration, &s.ResumeSqDistance, &s.MaxArea) if err != nil { return files, err } diff --git a/models/scoutHealth_test.go b/models/scoutHealth_test.go index 117cedc..bcc810b 100644 --- a/models/scoutHealth_test.go +++ b/models/scoutHealth_test.go @@ -38,7 +38,7 @@ var _ = Describe("Scout Health Model", func() { Context("Insert", func() { It("should insert a valid scouthealth into the DB.", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -63,7 +63,7 @@ var _ = Describe("Scout Health Model", func() { Context("Delete", func() { It("should be able to delete healths for a specified scout", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -85,7 +85,7 @@ var _ = Describe("Scout Health Model", func() { Context("Get", func() { It("should be able to get scout healths as json", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "idle", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) diff --git a/models/scoutLog_test.go b/models/scoutLog_test.go index 0ce6754..2096866 100644 --- a/models/scoutLog_test.go +++ b/models/scoutLog_test.go @@ -36,7 +36,7 @@ var _ = Describe("Scout Health Model", func() { Context("Insert", func() { It("should insert a valid scout_log into the DB.", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "calibrated", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -61,7 +61,7 @@ var _ = Describe("Scout Health Model", func() { Context("Delete", func() { It("should be able to delete logs for a specified scout", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "calibrated", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) diff --git a/models/scout_test.go b/models/scout_test.go index b7bab18..53cf119 100644 --- a/models/scout_test.go +++ b/models/scout_test.go @@ -69,7 +69,7 @@ var _ = Describe("Scout Model", func() { Context("Insert", func() { It("should insert a valid scout into the DB.", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "calibrated", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -80,7 +80,7 @@ var _ = Describe("Scout Model", func() { It("should return an error when an invalid scout is inserted into the DB.", func() { s := Scout{"aa", "192.168.0.1", 8080, true, "foo", "calibratingas", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).ShouldNot(BeNil()) Ω(s.UUID).Should(Equal("aa")) @@ -94,12 +94,12 @@ var _ = Describe("Scout Model", func() { Ω(len(al)).Should(Equal(0)) s1 := Scout{"", "192.168.0.1", 8080, true, "foo", "calibrated", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err = s1.Insert(db) Ω(err).Should(BeNil()) s2 := Scout{"", "192.168.0.2", 8080, true, "foo", "calibrated", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err = s2.Insert(db) Ω(err).Should(BeNil()) @@ -113,7 +113,7 @@ var _ = Describe("Scout Model", func() { Context("Update", func() { It("should be able to update a scout in the DB", func() { s := Scout{"", "192.168.0.1", 8080, true, "foo", "measuring", &ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) diff --git a/processes/monitor.go b/processes/monitor.go index f4e1000..fc09ee3 100644 --- a/processes/monitor.go +++ b/processes/monitor.go @@ -260,8 +260,8 @@ func measure(db *sql.DB, deltaC chan models.Command, videoFile string, debug boo for contours != nil { area := float64(C.cvContourArea(unsafe.Pointer(contours), C.cvSlice(0, 0x3fffffff), 0)) - // Only track large objects. - if area > s.MinArea { + // Only track appropriately sized objects. + if area > s.MinArea && area < s.MaxArea { boundingBox := C.cvBoundingRect(unsafe.Pointer(contours), 0) w := int(boundingBox.width / 2) h := int(boundingBox.height / 2) diff --git a/processes/summarise_test.go b/processes/summarise_test.go index 0751b3b..9a2ee8f 100644 --- a/processes/summarise_test.go +++ b/processes/summarise_test.go @@ -70,7 +70,7 @@ var _ = Describe("Summarise Process", func() { It("should ignore proccessed interactions", func() { s := models.Scout{"59ef7180-f6b2-4129-99bf-970eb4312b4b", "192.168.0.1", 8080, true, "foo", "calibrating", &models.ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -89,7 +89,7 @@ var _ = Describe("Summarise Process", func() { It("should increment the visitor count", func() { s := models.Scout{"59ef7180-f6b2-4129-99bf-970eb4312b4b", "192.168.0.1", 8080, true, "foo", "calibrating", &models.ScoutSummary{}, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil()) @@ -135,7 +135,7 @@ var _ = Describe("Summarise Process", func() { ss := &models.ScoutSummary{} s := models.Scout{"59ef7180-f6b2-4129-99bf-970eb4312b4b", "192.168.0.1", 8080, true, "foo", "calibrating", ss, - 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1} + 2.0, 2, 2, 2, 2, 2.0, 0, 2.0, 0.2, 0.3, 1, 4.0} err := s.Insert(db) Ω(err).Should(BeNil())