Renamed debug_viewer to debug_window to avoid confusion between year specific debug_viewer and debug_window.

Change-Id: I0bbd015f12abf3ffaabfd1181ff87f894a301495
diff --git a/aos/vision/blob/BUILD b/aos/vision/blob/BUILD
index cf728c5..7d57f50 100644
--- a/aos/vision/blob/BUILD
+++ b/aos/vision/blob/BUILD
@@ -100,6 +100,7 @@
   srcs = ['move_scale.cc'],
   deps = [
     ':range_image',
+    '//aos/vision/image:image_types',
   ],
 )
 
@@ -136,7 +137,7 @@
   hdrs = ['stream_view.h'],
   deps = [
     ':range_image',
-    '//aos/vision/debug:debug_viewer',
+    '//aos/vision/debug:debug_window',
     '//aos/vision/image:image_types',
   ],
 )
diff --git a/aos/vision/blob/move_scale.h b/aos/vision/blob/move_scale.h
index e45e14d..061da5c 100644
--- a/aos/vision/blob/move_scale.h
+++ b/aos/vision/blob/move_scale.h
@@ -5,18 +5,11 @@
 #include <vector>
 
 #include "aos/vision/blob/range_image.h"
+#include "aos/vision/image/image_types.h"
 
 namespace aos {
 namespace vision {
 
-// Bounding box for a RangeImage.
-struct ImageBBox {
-  int minx = std::numeric_limits<int>::max();
-  int maxx = std::numeric_limits<int>::min();
-  int miny = std::numeric_limits<int>::max();
-  int maxy = std::numeric_limits<int>::min();
-};
-
 // Sums img into bbox. bbox is constructed empty and grows with each call
 // to GetBBox.
 void GetBBox(const RangeImage &img, ImageBBox *bbox);
diff --git a/aos/vision/blob/stream_view.h b/aos/vision/blob/stream_view.h
index a6a661a..4cee7b4 100644
--- a/aos/vision/blob/stream_view.h
+++ b/aos/vision/blob/stream_view.h
@@ -2,7 +2,7 @@
 #define _AOS_VISION_BLOB_STREAM_VIEW_H_
 
 #include "aos/vision/blob/range_image.h"
-#include "aos/vision/debug/debug_viewer.h"
+#include "aos/vision/debug/debug_window.h"
 #include "aos/vision/image/image_types.h"
 
 #include <memory>
@@ -10,10 +10,10 @@
 namespace aos {
 namespace vision {
 
-class BlobStreamViewer : public DebugViewer {
+class BlobStreamViewer : public DebugWindow {
  public:
-  BlobStreamViewer() : DebugViewer(false) {}
-  explicit BlobStreamViewer(bool flip) : DebugViewer(flip) {}
+  BlobStreamViewer() : DebugWindow(false) {}
+  explicit BlobStreamViewer(bool flip) : DebugWindow(flip) {}
 
   void Submit(ImageFormat fmt, const BlobList &blob_list) {
     SetFormatAndClear(fmt);
@@ -77,7 +77,7 @@
   }
 
   // Backwards compatible.
-  DebugViewer *view() { return this; }
+  DebugWindow *view() { return this; }
 
   ImagePtr img() { return image_.get(); }
 
diff --git a/aos/vision/debug/BUILD b/aos/vision/debug/BUILD
index a96d25c..e9e45ad 100644
--- a/aos/vision/debug/BUILD
+++ b/aos/vision/debug/BUILD
@@ -11,9 +11,9 @@
         ],
 )
 
-gtk_dependent_cc_library(name = "debug_viewer",
-    srcs = ["debug_viewer.cc"],
-    hdrs = ["debug_viewer.h"],
+gtk_dependent_cc_library(name = "debug_window",
+    srcs = ["debug_window.cc"],
+    hdrs = ["debug_window.h"],
     deps = [
         '@usr_repo//:gtk+-3.0',
         "//aos/vision/image:image_types",
@@ -44,7 +44,6 @@
     '//aos/vision/image:jpeg_routines',
     '//aos/vision/image:image_stream',
     '//aos/vision/image:image_types',
-    '//aos/vision/debug:debug_viewer',
     '//aos/common/util:global_factory',
     '@usr_repo//:gtk+-3.0',
   ],
diff --git a/aos/vision/debug/blob_log-source.cc b/aos/vision/debug/blob_log-source.cc
index f707342..f2bfbb5 100644
--- a/aos/vision/debug/blob_log-source.cc
+++ b/aos/vision/debug/blob_log-source.cc
@@ -15,7 +15,7 @@
 
 namespace {
 
-long GetFileSize(const std::string& filename) {
+long GetFileSize(const std::string &filename) {
   struct stat stat_buf;
   int rc = stat(filename.c_str(), &stat_buf);
   return rc == 0 ? stat_buf.st_size : -1;
diff --git a/aos/vision/debug/debug_framework.cc b/aos/vision/debug/debug_framework.cc
index 99dfd8b..64f370c 100644
--- a/aos/vision/debug/debug_framework.cc
+++ b/aos/vision/debug/debug_framework.cc
@@ -6,7 +6,6 @@
 #include "aos/common/logging/logging.h"
 #include "aos/vision/blob/find_blob.h"
 #include "aos/vision/blob/stream_view.h"
-#include "aos/vision/debug/debug_viewer.h"
 #include "aos/vision/events/epoll_events.h"
 #include "aos/vision/image/jpeg_routines.h"
 
diff --git a/aos/vision/debug/debug_viewer.cc b/aos/vision/debug/debug_window.cc
similarity index 88%
rename from aos/vision/debug/debug_viewer.cc
rename to aos/vision/debug/debug_window.cc
index b0cf295..acbaf8e 100644
--- a/aos/vision/debug/debug_viewer.cc
+++ b/aos/vision/debug/debug_window.cc
@@ -1,4 +1,4 @@
-#include "aos/vision/debug/debug_viewer.h"
+#include "aos/vision/debug/debug_window.h"
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gtk/gtk.h>
@@ -26,7 +26,7 @@
   g_signal_connect(widget, "draw", G_CALLBACK(fnptr), obj);
 }
 
-struct DebugViewer::Internals {
+struct DebugWindow::Internals {
   Internals(bool flip) : flip_(flip) {}
 
   gboolean Draw(cairo_t *cr) {
@@ -73,18 +73,18 @@
   bool clear_per_frame_ = true;
 };
 
-void DebugViewer::SetOverlays(std::vector<OverlayBase *> *overlays) {
+void DebugWindow::SetOverlays(std::vector<OverlayBase *> *overlays) {
   self->overlays = overlays;
 }
 
-void DebugViewer::Redraw() {
+void DebugWindow::Redraw() {
   if (!self->needs_draw) {
     gtk_widget_queue_draw(self->drawing_area);
     self->needs_draw = true;
   }
 }
 
-void DebugViewer::UpdateImage(ImagePtr ptr) {
+void DebugWindow::UpdateImage(ImagePtr ptr) {
   if (ptr.data() != self->ptr.data()) {
     int w = ptr.fmt().w;
     int h = ptr.fmt().h;
@@ -107,11 +107,11 @@
   }
 }
 
-void DebugViewer::MoveTo(int x, int y) {
+void DebugWindow::MoveTo(int x, int y) {
   gtk_window_move(GTK_WINDOW(self->window), x, y);
 }
 
-void DebugViewer::SetScale(double scale_factor_inp) {
+void DebugWindow::SetScale(double scale_factor_inp) {
   int w = window_width_;
   int h = window_height_;
 
@@ -128,12 +128,12 @@
 gboolean debug_viewer_key_press_event(GtkWidget * /*widget*/,
                                       GdkEventKey *event, gpointer user_data) {
   auto &key_press_cb =
-      reinterpret_cast<DebugViewer *>(user_data)->key_press_event;
+      reinterpret_cast<DebugWindow *>(user_data)->key_press_event;
   if (key_press_cb) key_press_cb(event->keyval);
   return FALSE;
 }
 
-DebugViewer::DebugViewer(bool flip) : self(new Internals(flip)) {
+DebugWindow::DebugWindow(bool flip) : self(new Internals(flip)) {
   self->scale_factor = scale_factor;
   GtkWidget *window;
   auto drawing_area = self->drawing_area = gtk_drawing_area_new();
@@ -141,7 +141,7 @@
                               window_height_ * scale_factor);
   gtk_widget_add_events(drawing_area, GDK_KEY_PRESS_MASK);
 
-  g_draw_signal_connect<DebugViewer::Internals, &DebugViewer::Internals::Draw>(
+  g_draw_signal_connect<DebugWindow::Internals, &DebugWindow::Internals::Draw>(
       drawing_area, self.get());
 
   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -154,7 +154,7 @@
 
   gtk_container_add(GTK_CONTAINER(window), drawing_area);
 }
-DebugViewer::~DebugViewer() {}
+DebugWindow::~DebugWindow() {}
 
 void CairoRender::Text(int x, int y, int /*text_x*/, int /*text_y*/,
                        const std::string &text) {
diff --git a/aos/vision/debug/debug_viewer.h b/aos/vision/debug/debug_window.h
similarity index 90%
rename from aos/vision/debug/debug_viewer.h
rename to aos/vision/debug/debug_window.h
index ab2c716..906bf3b 100644
--- a/aos/vision/debug/debug_viewer.h
+++ b/aos/vision/debug/debug_window.h
@@ -1,5 +1,5 @@
-#ifndef AOS_VISION_DEBUG_DEBUG_VIEWER_H_
-#define AOS_VISION_DEBUG_DEBUG_VIEWER_H_
+#ifndef AOS_VISION_DEBUG_DEBUG_WINDOW_H_
+#define AOS_VISION_DEBUG_DEBUG_WINDOW_H_
 
 #include <cairo.h>
 #include <functional>
@@ -39,11 +39,11 @@
 };
 
 // Simple debug view window.
-class DebugViewer {
+class DebugWindow {
  public:
   struct Internals;
-  explicit DebugViewer(bool flip);
-  ~DebugViewer();
+  explicit DebugWindow(bool flip);
+  ~DebugWindow();
   // Explicit redraw queuing (Will not double-queue).
   void Redraw();
 
@@ -76,4 +76,4 @@
 }  // namespace vision
 }  // namespace aos
 
-#endif  // AOS_VISION_DEBUG_DEBUG_VIEWER_H_
+#endif  // AOS_VISION_DEBUG_DEBUG_WINDOW_H_
diff --git a/aos/vision/debug/overlay.h b/aos/vision/debug/overlay.h
index fbd6838..5a9804f 100644
--- a/aos/vision/debug/overlay.h
+++ b/aos/vision/debug/overlay.h
@@ -117,18 +117,39 @@
   ~PixelLinesOverlay() {}
 
   // build a segment for this line
-  void add_line(Vector<2> st, Vector<2> ed) { add_line(st, ed, color); }
+  void AddLine(Vector<2> st, Vector<2> ed) { AddLine(st, ed, color); }
 
   // build a segment for this line
-  void add_line(Vector<2> st, Vector<2> ed, PixelRef newColor) {
+  void AddLine(Vector<2> st, Vector<2> ed, PixelRef newColor) {
     lines_.emplace_back(
         std::pair<Segment<2>, PixelRef>(Segment<2>(st, ed), newColor));
   }
 
-  void start_new_profile() { start_profile = true; }
+  void DrawCross(aos::vision::Vector<2> center, int width,
+                 aos::vision::PixelRef color) {
+    using namespace aos::vision;
+    AddLine(Vector<2>(center.x() - width, center.y()),
+            Vector<2>(center.x() + width, center.y()), color);
+    AddLine(Vector<2>(center.x(), center.y() - width),
+            Vector<2>(center.x(), center.y() + width), color);
+  }
+
+  void DrawBBox(const ImageBBox &box, aos::vision::PixelRef color) {
+    using namespace aos::vision;
+    AddLine(Vector<2>(box.minx, box.miny), Vector<2>(box.maxx, box.miny),
+            color);
+    AddLine(Vector<2>(box.maxx, box.miny), Vector<2>(box.maxx, box.maxy),
+            color);
+    AddLine(Vector<2>(box.maxx, box.maxy), Vector<2>(box.minx, box.maxy),
+            color);
+    AddLine(Vector<2>(box.minx, box.maxy), Vector<2>(box.minx, box.miny),
+            color);
+  }
+
+  void StartNewProfile() { start_profile = true; }
 
   // add a new point connected to the last point in the line
-  void add_point(Vector<2> pt, PixelRef newColor) {
+  void AddPoint(Vector<2> pt, PixelRef newColor) {
     if (lines_.empty() || start_profile) {
       lines_.emplace_back(
           std::pair<Segment<2>, PixelRef>(Segment<2>(pt, pt), newColor));
diff --git a/aos/vision/debug/tcp-source.cc b/aos/vision/debug/tcp-source.cc
index 28feff3..37c38d5 100644
--- a/aos/vision/debug/tcp-source.cc
+++ b/aos/vision/debug/tcp-source.cc
@@ -76,7 +76,8 @@
    public:
     Impl(const std::string &hostname, int portno,
          DebugFrameworkInterface *interface)
-        : aos::events::TcpClient(hostname.c_str(), portno), interface_(interface) {}
+        : aos::events::TcpClient(hostname.c_str(), portno),
+          interface_(interface) {}
 
     void ReadEvent() override {
       read_.up(fd(), [&](DataRef data) {
diff --git a/aos/vision/image/image_types.h b/aos/vision/image/image_types.h
index 68e6d67..f8e5e65 100644
--- a/aos/vision/image/image_types.h
+++ b/aos/vision/image/image_types.h
@@ -12,6 +12,14 @@
 namespace aos {
 namespace vision {
 
+// Bounding box for a RangeImage.
+struct ImageBBox {
+  int minx = std::numeric_limits<int>::max();
+  int maxx = std::numeric_limits<int>::min();
+  int miny = std::numeric_limits<int>::max();
+  int maxy = std::numeric_limits<int>::min();
+};
+
 // This will go into c++17. No sense writing my own version.
 using DataRef = std::experimental::string_view;
 
diff --git a/aos/vision/image/reader.cc b/aos/vision/image/reader.cc
index 3a4b349..03e2fc8 100644
--- a/aos/vision/image/reader.cc
+++ b/aos/vision/image/reader.cc
@@ -237,7 +237,6 @@
     LOG(FATAL, "Failed to set up camera\n");
   }
 
-  // #if 0
   // set framerate
   struct v4l2_streamparm *setfps;
   setfps = (struct v4l2_streamparm *)calloc(1, sizeof(struct v4l2_streamparm));
@@ -251,7 +250,6 @@
   LOG(INFO, "framerate ended up at %d/%d\n",
       setfps->parm.capture.timeperframe.numerator,
       setfps->parm.capture.timeperframe.denominator);
-  // #endif
 }
 
 aos::vision::ImageFormat Reader::get_format() {
diff --git a/y2016/vision/target_sender.cc b/y2016/vision/target_sender.cc
index 706c348..2790a83 100644
--- a/y2016/vision/target_sender.cc
+++ b/y2016/vision/target_sender.cc
@@ -228,12 +228,12 @@
   std::thread cam0([stereo]() {
     RunCamera(0, GetCameraParams(stereo.calibration()),
               stereo.calibration().right_camera_name(),
-              stereo.calibration().roborio_ip_addr(), 8082);
+              stereo.calibration().roborio_ip_addr(), 8080);
   });
   std::thread cam1([stereo]() {
     RunCamera(1, GetCameraParams(stereo.calibration()),
               stereo.calibration().left_camera_name(),
-              stereo.calibration().roborio_ip_addr(), 8082);
+              stereo.calibration().roborio_ip_addr(), 8080);
   });
   cam0.join();
   cam1.join();