Home Image-Pro Automation (Macros, Apps, Reports)

Is there a way to add object count from the data collector to a report?

I am using the data collector to aggregate measurements from multiple images to count enough objects for my statistics. I then want to create a report that includes an entry with the total number of counted object. I can get the data collector easily enough, but I'm not sure how to get a total count.

Best Answer

  • edited January 2014 Answer ✓
    You could use the count summary, which is available for all these tables.


    image

Answers

  • Thanks, that's the ticket.
  • I've been trying to add this value to a table so the report looks a little more elegant, but if I copy the summary field it copies the values, rather than the link to the data collector data. Is there any way to get a table with just the summary values without the rather inelegant "Region:Measurement:Diameter Max-Average:" prefix?
  • edited January 2014
    The next Image-Pro Premier release will introduce an easier way to include measurements statistics in Data Collector and in reports for single images.

    In the more general case, in order to have full control over the layout of your data, and statistics specifically, you have the option of adding your own data to the report using "code behind" which consists of small macros that are used to drive the report.

    Your modified sample report is attached with an implementation of this approach which produces the table you were looking for.

    image
    The code needed for this (included in the report, see code view)  is as follows:

    Imports System.Data
    
    Public Class arieh
    
        ' Statistics table
        Private _dataSet As DataSet
        Private _dtStatistics As DataTable
    
        Private Sub ThisReport_RefreshSchema(ByVal source As Object, ByVal args As MediaCy.Addins.Reporter.ReportEventArgs) Handles ThisReport.RefreshSchema
            ' Add new table for Data Collector statistics
            _dataSet = New DataSet
            _dtStatistics = _dataSet.Tables.add("Statistics")
            _dtStatistics.Columns.Add("Measure")
            _dtStatistics.Columns.Add("Value",GetType(Double))
            args.Report.DataSources.Add("Data Statistics",_dtStatistics,_dataSet)
        End Sub
    
        Private Sub ThisReport_RefreshData(ByVal source As Object, ByVal args As MediaCy.Addins.Reporter.ReportEventArgs) Handles ThisReport.RefreshData
            ' Fill new data table
            If _dtStatistics.Rows.Count=0 Then
                If args.Report.DataSources.Item("Data Collector") IsNot Nothing Then
                    Dim dsDataCollector As DataSet = args.Report.DataSources.Item("Data Collector").DataRoot
                    If dsDataCollector.Tables.Contains("Measurements") Then
                        Dim dtMeasurements As DataTable = dsDataCollector.Tables.Item("Measurements")
                        _dtStatistics.Rows.Add("Diameter Max (Average)", dtMeasurements.Compute("Avg(mRgnMaxDiameter)",""))
                        _dtStatistics.Rows.Add("Diameter Mean (Average)", dtMeasurements.Compute("Avg(mRgnMeanDiameter)",""))
                        _dtStatistics.Rows.Add("Diameter Min (Average)", dtMeasurements.Compute("Avg(mRgnMinDiameter)",""))
                        _dtStatistics.Rows.Add("Roundness (Average)", dtMeasurements.Compute("Avg(mRgnRoundness)",""))
                        _dtStatistics.Rows.Add("Roundness (Max)", dtMeasurements.Compute("Max(mRgnRoundness)",""))
                        _dtStatistics.Rows.Add("Object Count)", dtMeasurements.Rows.Count)
                    End If
                End If
            End If
        End Sub
    
    End Class
Sign In or Register to comment.