- // Determine the width of the can at this row
- //widths[i] = edges[1] - edges[0];
- average_width += (edges[1] - edges[0]);
+ if( num > 0)
+ {
+ average += ( edge_location / num );
+ num_edges++;
+ }
+ }
+ if (num_edges > 0)
+ average /= num_edges;
+
+ if( average > 0)
+ {
+ result = true; //Successfully found an edge
+ *value = average;
+ }
+ return result;
+}
+
+ /**
+ * Read the dilatometer image. The value changed will correspond to the new location of the edge.
+ * @param val - Will store the read value if successful
+ * @returns true on successful read
+ */
+bool Dilatometer_Read( double * value)
+{
+ bool result = Dilatometer_GetEdge(value, SAMPLES);
+ return result;
+}
+
+/**
+ * Initialise the dilatometer
+ */
+void Dilatometer_Init()
+{
+ // Make an initial reading (will allocate memory the first time only).
+ double val;
+ Dilatometer_GetEdge(&val, 1);
+}
+
+// Overlays a line over the given edge position
+void Draw_Edge(double edge)
+{
+ CvScalar value;
+ value.val[0]=244;
+ for( int i = 0; i < g_srcGray->rows; i++)
+ {
+ cvSet2D(g_edges,i,edge,value);