Exemple #1
0
        public static void SaveAggregatedResultImagesLocally(string jobGUID, string directoryName)
        {
            //SatyamAggregatedResultsTableAccess resultsDB = new SatyamAggregatedResultsTableAccess();
            //List<SatyamAggregatedResultsTableEntry> entries = resultsDB.getEntriesByGUID(jobGUID);
            //resultsDB.close();
            //SaveAggregatedResultImagesLocally(entries, directoryName);
            SatyamAggregatedProgressiveResultsTableAccess       resultsDB = new SatyamAggregatedProgressiveResultsTableAccess();
            List <SatyamAggregatedProgressiveResultsTableEntry> entries   = resultsDB.getEntriesByGUID(jobGUID);

            resultsDB.close();
            SaveAggregatedProgressiveResultImagesLocally(entries, directoryName);
        }
Exemple #2
0
        public static string GetAggregatedResultString(List <SatyamResultsTableEntry> results)
        {
            if (results.Count == 0)
            {
                return(null);
            }

            List <MultiObjectLocalizationAndLabelingResult> resultList = new List <MultiObjectLocalizationAndLabelingResult>();
            List <string> WorkersPerTask = new List <string>();

            foreach (SatyamResultsTableEntry entry in results)
            {
                SatyamResult res = JSonUtils.ConvertJSonToObject <SatyamResult>(entry.ResultString);

                // remove duplicate workers result
                // "" works for internal test!!!
                string workerID = res.amazonInfo.WorkerID;
                if (workerID != "" && WorkersPerTask.Contains(workerID))
                {
                    continue;
                }
                //enclose only non-duplicate results, one per each worker.
                WorkersPerTask.Add(workerID);

                MultiObjectLocalizationAndLabelingResult taskr = JSonUtils.ConvertJSonToObject <MultiObjectLocalizationAndLabelingResult>(res.TaskResult);
                resultList.Add(taskr);
            }

            /// Store Progressive results in progressive table, for consensus loading on turker task pages.
            // check  if there are any new valid results first
            SatyamAggregatedProgressiveResultsTableAccess progDBtemp = new SatyamAggregatedProgressiveResultsTableAccess();
            int LatestResultsAggregated = progDBtemp.getLatestNoResultsAggregatedByTaskID(results[0].SatyamTaskTableEntryID);// default value is -1

            progDBtemp.close();

            if (LatestResultsAggregated >= resultList.Count)
            {
                return(null);
            }
            /// safely return null here, since if it's aggregated by standard, it won't be executed again.
            /// it will be only executed when there is no standard aggregation result.
            /// so return null when no new results came in to even produce a progress aggregation result.


            int MaxCount = Math.Min(resultList.Count, TaskConstants.MULTI_OBJECT_LOCALIZATION_AND_LABLING_MTURK_MAX_RESULTS_TO_AGGREGATE);
            MultiObjectLocalizationAndLabelingAggregatedResult tempr = getAggregatedResult(resultList, MinResults: 2);

            if (tempr != null)
            {
                string rString = JSonUtils.ConvertObjectToJSon <MultiObjectLocalizationAndLabelingAggregatedResult>(tempr);
                SatyamAggregatedResult aggResult = new SatyamAggregatedResult();
                aggResult.SatyamTaskTableEntryID = results[0].SatyamTaskTableEntryID;
                aggResult.AggregatedResultString = rString;
                SatyamResult res = JSonUtils.ConvertJSonToObject <SatyamResult>(results[0].ResultString);
                aggResult.TaskParameters = res.TaskParametersString;
                string resultString = JSonUtils.ConvertObjectToJSon <SatyamAggregatedResult>(aggResult);

                // create progressive entry
                SatyamAggregatedProgressiveResultsTableEntry aggProgEntry = new SatyamAggregatedProgressiveResultsTableEntry();
                aggProgEntry.JobGUID                = results[0].JobGUID;
                aggProgEntry.JobTemplateType        = results[0].JobTemplateType;
                aggProgEntry.SatyamTaskTableEntryID = results[0].SatyamTaskTableEntryID;
                aggProgEntry.UserID            = results[0].UserID;
                aggProgEntry.ResultString      = resultString;
                aggProgEntry.ResultsAggregated = resultList.Count; // use the actual valid non-duplicate results number here.
                SatyamAggregatedProgressiveResultsTableAccess aggProgDB = new SatyamAggregatedProgressiveResultsTableAccess();
                aggProgDB.AddEntry(aggProgEntry);
                aggProgDB.close();
            }
            else
            {
                return(null);
            }


            MultiObjectLocalizationAndLabelingAggregatedResult r = getAggregatedResult(resultList);

            if (r != null)
            {
                string rString = JSonUtils.ConvertObjectToJSon <MultiObjectLocalizationAndLabelingAggregatedResult>(r);
                SatyamAggregatedResult aggResult = new SatyamAggregatedResult();
                aggResult.SatyamTaskTableEntryID = results[0].SatyamTaskTableEntryID;
                aggResult.AggregatedResultString = rString;
                SatyamResult res = JSonUtils.ConvertJSonToObject <SatyamResult>(results[0].ResultString);
                aggResult.TaskParameters = res.TaskParametersString;
                string resultString = JSonUtils.ConvertObjectToJSon <SatyamAggregatedResult>(aggResult);
                return(resultString);
            }
            else
            {
                return(null);
            }
        }