def RunVisualUtilityFilter(bag, nodeName):

    # First go through the bag and get the parameters
    paramList = [(NormalizeParamName(msg.name.data),
                  ToNumIfPossible(msg.value.data))
                 for topic, msg, t in bag.read_messages(topics=['parameters'])]
    paramList.append(('visual_debugging', True))
    parameters = ParameterSetter(nodeName, paramList)

    # Start the visual utility filter
    serviceName = '%s/filter_image_service' % nodeName

    rospy.loginfo('Running the visual utility filter')
    proc = subprocess.Popen([
        'rosrun', 'visual_utility', 'VisualUtilityFilterNode',
        '__name:=' + nodeName,
        'image:=%s/left_image' % nodeName,
        'filtered/image:=%s/filtered/image' % nodeName,
        'object_detected:=%s/object_detected' % nodeName,
        'processing_time:=%s/processing_time' % nodeName,
        'debug/vuestimate:=%s/debug/vuestimate' % nodeName,
        'debug/mosaic:=%s/debug/mosaic' % nodeName,
        'debug/frameImage:=%s/debug/frameImage' % nodeName,
        'filter_image_service:=%s' % serviceName
    ])

    rospy.loginfo('Waiting for the visual utility filter to startup')
    rospy.wait_for_service(serviceName, timeout=6000)
    rospy.loginfo('Visual utility filter is running')
    serviceProxy = rospy.ServiceProxy(serviceName, FilterImage)

    return (proc, parameters, serviceProxy)
Exemple #2
0
def StartSpeciesIDNode(outputDir, namespace, outBag, bagTime, paramList,
                       indexFilename):
    rospy.loginfo('Running the SpeciesIDNode')
    nodeName = '%s_species_id_node' % namespace
    serviceName = '%s/detect_object_grid_service' % nodeName
    params = copy.deepcopy(paramList)
    params.append(('index_file', indexFilename))
    parameterHandler = ParameterSetter(nodeName, params, outBag, 'parameters',
                                       bagTime)

    vuEnv = os.environ
    #vuEnv['CPUPROFILE'] = '/home/mdesnoye/tmp/fish_classifier.prof'

    proc = subprocess.Popen([
        'bin/SpeciesIDRosNode', '__name:=' + nodeName,
        '__log:=%s/%s_log.out' % (outputDir, nodeName),
        'species_id_grid_service:=%s' % serviceName
    ],
                            env=vuEnv)

    rospy.loginfo('Waiting for the SpeciesIDNode to startup')
    rospy.wait_for_service(serviceName, timeout=6000)
    rospy.loginfo('SpeciesIDNode is running')

    serviceProxy = rospy.ServiceProxy(serviceName, SpeciesIDGrid)

    return (proc, parameterHandler, serviceProxy)
Exemple #3
0
def StartPersonDetector(outputDir, namespace, modelFile, personCascade,
                        personThresh, parameterBag, bagTime):
    rospy.loginfo('Running the person detector')

    nodeName = '%s_person_detector' % namespace
    serviceName = '%s/detect_object_service' % nodeName
    parameters = ParameterSetter(nodeName, [('model_file', modelFile),
                                            ('thresh', personThresh),
                                            ('do_cascade', personCascade)],
                                 parameterBag, 'parameters', bagTime)

    proc = subprocess.Popen([
        'rosrun', 'cascade_parts_detector', 'CascadePartsDetectorNode',
        '__name:=' + nodeName,
        '__log:=%s/%s_log.out' % (outputDir, nodeName),
        'detect_object_service:=%s' % serviceName,
        'detect_object:=%s/detect_object' % nodeName,
        'object_detected:=%s/object_detected' % nodeName,
        'processing_time:=%s/processing_time' % nodeName
    ])

    rospy.loginfo('Waiting for the person detector to come up')
    rospy.wait_for_service(serviceName, timeout=6000)
    rospy.loginfo('Person detector is running')
    serviceProxy = rospy.ServiceProxy(serviceName, DetectObject)

    return (proc, parameters, serviceProxy)
Exemple #4
0
def StartSubDetector(outputDir, namespace, nodeName, outBag, bagTime,
                     parameterList):
    rospy.loginfo('Running the subdetector %s' % nodeName)

    nodeId = '%s_%s' % (namespace, nodeName)
    serviceName = '%s/detect_object_service' % nodeId
    parameters = ParameterSetter(nodeId, parameterList, outBag,
                                 'parameters_%s' % nodeName, bagTime)

    vuEnv = os.environ
    #vuEnv['CPUPROFILE'] = '/home/mdesnoye/tmp/%s_%s.prof' % (nodeName, namespace)
    #rospy.loginfo('Profiling the visual utility estimator to %s' %
    #              vuEnv['CPUPROFILE'])

    proc = subprocess.Popen([
        '../visual_utility/bin/VisualUtilityEstimatorNode',
        '__name:=' + nodeId,
        '__log:=%s/%s_log.out' % (outputDir, nodeId),
        'vu_objdetect_service:=%s' % serviceName
    ],
                            env=vuEnv)

    rospy.loginfo('Waiting for %s to startup' % nodeId)
    rospy.wait_for_service(serviceName, timeout=6000)
    rospy.loginfo('%s is running' % nodeId)
    serviceProxy = rospy.ServiceProxy(serviceName, DetectObjectService)

    return (proc, parameters, serviceProxy)
Exemple #5
0
def StartVisualUtilityEstimator(outputDir, namespace, outBag, bagTime,
                                options):
    rospy.loginfo('Running the Visual Utility Estimator')

    nodeName = '%s_vu_estimator' % namespace
    serviceName = '%s/detect_object_grid_service' % nodeName
    parameterList = [('affine_max_iterations', options.affine_max_iterations),
                     ('min_affine_precision', options.min_affine_precision),
                     ('affine_scaling_factor', options.affine_scaling_factor),
                     ('vu_estimator', options.vu_estimator),
                     ('vu_estimator_wrapper', options.vu_estimator_wrapper),
                     ('pareto_thresh', options.pareto_thresh),
                     ('dist_decay', options.dist_decay),
                     ('opening_size', options.opening_size),
                     ('laplacian_size', options.laplacian_size),
                     ('hist_dist_type', options.hist_dist_type),
                     ('estimator_scales', options.estimator_scales),
                     ('hog_model_file', options.hog_model_file),
                     ('hog_do_people', options.hog_do_people),
                     ('hog_do_cache', options.hog_do_cache),
                     ('win_stride', options.win_stride),
                     ('img_scaling', options.img_scaling),
                     ('cascade_model_file', options.cascade_model_file)]
    parameters = ParameterSetter(nodeName, parameterList, outBag, 'parameters',
                                 bagTime)

    vuEnv = os.environ
    #vuEnv['CPUPROFILE'] = '/home/mdesnoye/tmp/vu_saliency.prof'

    proc = subprocess.Popen([
        '../visual_utility/bin/VisualUtilityEstimatorNode',
        '__name:=' + nodeName,
        '__log:=%s/%s_log.out' % (outputDir, nodeName),
        'vu_objdetect_grid_service:=%s' % serviceName
    ],
                            env=vuEnv)

    rospy.loginfo('Waiting for the visual utility estimator to startup')
    rospy.wait_for_service(serviceName, timeout=6000)
    rospy.loginfo('Visual utility filter is running')
    serviceProxy = rospy.ServiceProxy(serviceName, DetectObjectGridService)

    return (proc, parameters, serviceProxy)
Exemple #6
0
def StartVisualUtilityFilter(outputDir, namespace, transformEstimator,
                             affineMaxIterations, minAffinePrecision,
                             affineScalingFactor, vuEstimator, paretoThresh,
                             distDecay, vuMosaic, morphCloseSize, gaussSigma,
                             frameEstimator, frameExpansion, framesize,
                             minFrameArea, minEntropy, parameterBag, bagTime):
    rospy.loginfo('Running the visual utility filter')

    nodeName = '%s_vufilter' % namespace
    serviceName = '%s/filter_image_service' % nodeName
    parameters = ParameterSetter(
        nodeName, [('affine_max_iterations', affineMaxIterations),
                   ('min_affine_precision', minAffinePrecision),
                   ('affine_scaling_factor', affineScalingFactor),
                   ('vu_estimator', vuEstimator),
                   ('pareto_thresh', paretoThresh), ('dist_decay', distDecay),
                   ('frame_estimator', frameEstimator),
                   ('frame_expansion', frameExpansion),
                   ('morph_close_size', morphCloseSize),
                   ('gauss_sigma', gaussSigma), ('xframesize', framesize[0]),
                   ('yframesize', framesize[1]),
                   ('min_frame_area', minFrameArea),
                   ('min_entropy', minEntropy)], parameterBag, 'parameters',
        bagTime)

    proc = subprocess.Popen([
        'rosrun', 'visual_utility', 'VisualUtilityFilterNode',
        '__name:=' + nodeName,
        '__log:=%s/%s_log.out' % (outputDir, nodeName),
        'image:=%s/left_image' % nodeName,
        'filtered/image:=%s/filtered/image' % nodeName,
        'object_detected:=%s/object_detected' % nodeName,
        'processing_time:=%s/processing_time' % nodeName,
        'filter_image_service:=%s' % serviceName
    ])

    rospy.loginfo('Waiting for the visual utility filter to startup')
    rospy.wait_for_service(serviceName, timeout=6000)
    rospy.loginfo('Visual utility filter is running')
    serviceProxy = rospy.ServiceProxy(serviceName, FilterImage)

    return (proc, parameters, serviceProxy)