示例#1
0
def find_nodejs():
    candidates = [
        '/opt/nodejs-9.4.0/bin/nodejs',
    ]

    # More location candidates from the system
    candidates += where.where('node')
    candidates += where.where('nodejs')

    return find_program_candidate(candidates)
示例#2
0
def find_convert():
    """
    Debian: aptitude install imagemagick
    /usr/bin/convert

    Mac OS X with Homebrew
    /usr/local/bin/convert

    Mac OS X with Macports
    /opt/local/bin/convert

    Self-compiled
    /opt/imagemagick/bin/convert
    /opt/imagemagick-7.0.2/bin/convert
    """

    # Some nailed location candidates
    candidates = [
        '/opt/imagemagick-7.0.2/bin/convert',
        '/opt/imagemagick/bin/convert',
        '/usr/local/bin/convert',
        '/opt/local/bin/convert',
        '/usr/bin/convert',
    ]

    # More location candidates from the system
    candidates += where.where('convert')

    # Find location of "convert" program
    convert_path = find_program_candidate(candidates)

    logger.info('Found "convert" program at {}'.format(convert_path))
    return convert_path
示例#3
0
 def find_firefox(cls):
     candidates = where.where('firefox')
     candidates += [
         '/Applications/Firefox.app/Contents/MacOS/firefox-bin',
     ]
     firefox = find_program_candidate(candidates)
     logger.info('Found "firefox" program at {}'.format(firefox))
     return firefox
示例#4
0
def find_decktape():
    candidates = [
        './node_modules/.bin/decktape',
        '/opt/nodejs-9.4.0/bin/decktape',
    ]

    # More location candidates from the system
    candidates += where.where('decktape')

    return find_program_candidate(candidates)
示例#5
0
 def find_unoconv():
     # Debian: aptitude install unoconv
     # Mac OS X: brew install unoconv
     # TODO: Make unoconv configurable via ini file
     candidates = [
         # LibreOffice 4.x on Mac OSX 10.7, YMMV
         '/Applications/LibreOffice.app/Contents/program/LibreOfficePython.framework/bin/unoconv',
         '/usr/bin/unoconv',
     ]
     candidates += where.where('unoconv')
     for candidate in candidates:
         if os.path.isfile(candidate):
             return candidate
示例#6
0
def tapetest():
    parser = argparse.ArgumentParser(description='')
    parser.add_argument(
        'data_set',
        help='The location of the data set. If '
        'names specified in a lookup file can be selected with a prefix of '
        '{0}.'.format(where.named_location))
    args = parser.parse_args()

    args.data_set = where.where(args.data_set)

    taper = tapeworm.Taper(args.data_set, verbosity=1)
    taper.load_data()

    for i, _ in enumerate(taper.segments()):
        print(i, end=' ')
示例#7
0
def find_pdftk():
    """
    Debian: aptitude install pdftk
    /usr/bin/pdftk

    Mac OS X
    /opt/pdflabs/pdftk/bin/pdftk

    Self-compiled
    /usr/local/bin/pdftk
    """

    candidates = [
        '/opt/pdflabs/pdftk/bin/pdftk',
        '/usr/local/bin/pdftk',
        '/usr/bin/pdftk',
    ]

    # More location candidates from the system
    candidates += where.where('pdftk')

    return find_program_candidate(candidates)
示例#8
0
def main(argv=None):
    if argv is None:
        argv = sys.argv

    # parser = argparse.ArgumentParser(description='Get basic information '
    #     'about a particular blob.')

    # parser.add_argument('--data-set', default='%pics1',
    #     help='The location of the data set. If names specified in a lookup '
    #     'file can be selected with a prefix of {0}.'.format(
    #         where.named_location))
    # parser.add_argument('--blob-id', type=int, help='The blob ID in the '
    #     'data set to summarize.')
    # parser.add_argument('-ht', '--head-and-tail', action='store_true')

    # args = parser.parse_args()

    data_set = where.where('%pics2')

    experiment = tape.MultiblobExperiment(data_set)
    experiment.load_summary()

    segments = [[4478, 4980, 7817], [4980, 7817], [7817], 7817]

    for seg in segments:
        patched_blob = experiment.parse_blob(seg)
        #patched_blob = experiment.parse_blob([4478, 1, 7817]) # should fail

        f_no = patched_blob['frame'][0]
        for frame in patched_blob['frame']:
            if f_no != frame:
                print("ERROR: Discontinuity from frame {0} to {1}".format(
                    f_no - 1, frame))
                f_no = frame
            f_no += 1
    print('Done.')
示例#9
0
def test_where_where_executes():
    import where
    where.where("python")
示例#10
0
def test_where_where_executes():
    where.where("python")
示例#11
0
def main():
    parser = argparse.ArgumentParser(description='Get basic information '
                                     'about an experiment.')

    parser.add_argument(
        'data_set',
        help='The location of the data set. If '
        'names specified in a lookup file can be selected with a prefix of '
        '{0}.'.format(where.named_location).replace('%', '%%'))
    parser.add_argument('-l',
                        '--limit',
                        type=int,
                        help='Limit the number '
                        'of blobs to process')
    parser.add_argument('-p',
                        '--plot',
                        action='store_true',
                        help='Show a '
                        'plot (if supported by another command)')
    parser.add_argument('-j',
                        '--json',
                        action='store_true',
                        help='Dump '
                        'data to a JSON.')

    args = parser.parse_args()

    args.data_set = where.where(args.data_set)

    experiment = multiworm.Experiment(args.data_set)
    experiment.load_summary()

    experiment.add_summary_filter(
        multiworm.filters.summary_lifetime_minimum(120))
    experiment.add_filter(multiworm.filters.relative_move_minimum(2))

    if args.limit:
        blob_gen = itertools.islice(experiment.good_blobs(), args.limit)
    else:
        blob_gen = experiment.good_blobs()

    speed_config = {
        'smoothing': ('sgolay', 71, 5),
        'percentiles': [10, 20, 50, 80, 90],
    }

    noise_est = multiworm.analytics.NoiseEstimator()
    speed_est = multiworm.analytics.SpeedEstimator(**speed_config)

    analyzer = multiworm.analytics.ExperimentAnalyzer()
    analyzer.add_analysis_method(noise_est)
    analyzer.add_analysis_method(speed_est)

    analyzer.analyze(blob_gen)

    data = analyzer.results()

    if args.json:
        print(json.dumps(data, indent=4))

    else:
        print('Mean X/Y              : ', data['noise']['mean_xy'])
        print('Standard Deviation X/Y: ', data['noise']['std_dev_xy'])

    if args.plot:
        import matplotlib.pyplot as plt

        f, axs = plt.subplots(ncols=2)
        f.suptitle(
            'Normal summary statistics for frame-by-frame centroid steps')
        for ax, data, title in zip(
                axs, [data['noise']['means'], data['noise']['std_devs']],
            ['X/Y means', 'X/Y stddev']):
            ax.scatter(*zip(*data))
            ax.set_title(title)
            ax.axvline()
            ax.axhline()
            ax.axis('equal')

        axs[1].set_xlim(left=0)
        axs[1].set_ylim(bottom=0)

        plt.show()
示例#12
0
def test_cases():
	global debug_label
	global debug_pos_err

	rms_clc_a_err = 0.0
	rms_clc_r_err = 0.0
	cnt = 0

	for south in range (60, 241, 10):
		for east in range (-60, +61, 10):
			for t in (where.MID_LEFT, where.LOW, where.MID_RIGHT):
				az = math.degrees(math.atan2( where.target_locs[t].center_east-east, south+15.0 ))
				debug_label = 'az={0:6.1f}(deg) e={1:6.1f}(in) s={2:6.1f}(in)'.format(az, east, south) 
				#
                                # Step 0g
                                #
				# Project the image on to the camera, identify the complete targets in the field of view
                                #
				constructed_rectangles = construct_test_image( 
                                    math.radians(float(az)), # Rotate Right - (Azimuth)   - radians 
                                    0.0,                     # Tilt Up      - (Elevation) - radians
				    float(east),             # Shift Right  - (East)      - inches
				    54.0,                    # Shift Up     - (Up)        - inches
                                    float(-south)  )         # Shift Forward- (North)     - inches
                                #
				# Start with an empty list of targets
				targets = []			
 				#
				# Perform Step 1 on all the target rectangles in the field of view
				#
				for r in constructed_rectangles:
                                        #       edges:               left, right,  top, bottom     : in pixels
					targets.append( where.target( r[0], r[1], r[2],   r[3] ) )

				# Perform Steps 2 through 12 on the target set of rectangles in the field of view
				#
				calc_az, calc_east, calc_south = where.where( targets )

				# calc_south = -1000 if we did not find two targets in the field of view
				#
				# if we found at least 2 targets in the camera field of view
				if calc_south != -1000 :
					debug_pos_err = 'heading-err={0:6.1f}(deg) east-err={1:6.1f}(in) south-err={2:6.1f}(in)'.format(
						az-math.degrees(calc_az), calc_east-east, calc_south - south)
					#
					# Find the target we were aiming at in this test case
					for r in targets:
                                           if r.pos == t :
						   #
						   # Perform step 13
						   # Calculate the azimuth offset from the center of the backboard to the
						   # center of the hoop
						   calc_target_az, calc_az_offset = where.target_backboard_az_and_az_offset( 
							   r, calc_east, calc_south )
						   #
						   # Perform step 14
						   # Calculate the range from the camera to the center of the hoop
						   calc_target_range              = where.target_range( r, calc_east, calc_south )

						   #
						   # Calculate the actual (ideal) azimuth offset and range assuming
						   # that we had no errors calculating where we were at and calculating
						   # our heading
						   #
						   actual_target_az, az_offset    = where.target_backboard_az_and_az_offset( 
							   r, east, south )
						   actual_target_range            = where.target_range( r, east, south)

						   #
						   # Accumulate Root Mean Square (RMS) Heading and Range for this test run
						   #
						   cnt = cnt + 1						   
						   rms_clc_a_err = rms_clc_a_err + math.pow( calc_az_offset-az_offset,2 )
						   rms_clc_r_err = rms_clc_a_err + math.pow( calc_target_range-actual_target_range,2 )

						   print '{0:s} {1:s} in-view:{2:s} target:{3:s} az-err-to-hoop={4:4.1f}(deg) range-err-to-hoop={5:4.1f}(in)'.format(
							debug_label, debug_pos_err, where.debug_found, target_name[r.pos], 
							math.degrees(calc_az_offset-az_offset), calc_target_range - actual_target_range)
				else:
					debug_pos_err = '---------------------------------------'

	#
	# Print the RMS errors
	#
	print 'rms_clc_r_err={0:10.7f} rms_clc_a_err={1:10.7f}'.format( math.sqrt(rms_clc_r_err/cnt), math.degrees(math.sqrt(rms_clc_a_err/cnt)) ) 
示例#13
0
def test_cases():
	global debug_label
	global debug_pos_err

        f_csv = open( 'output.csv', 'w' )
        printedHeader = 0

	rms_clc_a_err = 0.0
	rms_clc_r_err = 0.0
	cnt = 0

	for south in range (60, 241, 10):
		for east in range (-60, +61, 10):
			for t in (where.MID_LEFT, where.LOW, where.MID_RIGHT):
				az = math.degrees(math.atan2( where.target_locs[t].center_east-east, south+15.0 ))
				debug_label = 'az={0:6.1f}(deg) e={1:6.1f}(in) s={2:6.1f}(in)'.format(az, east, south) 
				#
                                # Step 0g
                                #
				# Project the image on to the camera, identify the complete targets in the field of view
                                #
				constructed_rectangles = construct_test_image( 
                                    math.radians(float(az)), # Rotate Right - (Azimuth)   - radians 
                                    0.0,                     # Tilt Up      - (Elevation) - radians
				    float(east),             # Shift Right  - (East)      - inches
				    54.0,                    # Shift Up     - (Up)        - inches
                                    float(-south)  )         # Shift Forward- (North)     - inches
                                #
				# Start with an empty list of targets
				targets = []			
                                # Start with a empty csv and header list
                                header = []
                                csv = []
                                header.append( "south (in)" )
                                csv.append( south )
                                header.append( "east (in)" )
                                csv.append( east )
                                header.append( "az  (deg)" )
                                csv.append( az )
 				#
				# Perform Step 1 on all the target rectangles in the field of view
				#
				for r in constructed_rectangles:
                                        #       edges:               left, right,  top, bottom     : in pixels
					targets.append( where.target( r[0], r[1], r[2],   r[3] ) )
                                        header.append( "left (pix)" )
                                        csv.append( r[0] )
                                        header.append( "rght (pix)" )
                                        csv.append( r[1] )
                                        header.append( "top  (pix)" )
                                        csv.append( r[2] )
                                        header.append( "bot  (pix)" )
                                        csv.append( r[3] )

                                for i in range( len(constructed_rectangles), 4 ):
                                        header.append( "left (pix)" )
                                        csv.append( -1 )
                                        header.append( "rght (pix)" )
                                        csv.append( -1 )
                                        header.append( "top  (pix)" )
                                        csv.append( -1 )
                                        header.append( "bot  (pix)" )
                                        csv.append( -1 )

				# Perform Steps 2 through 12 on the target set of rectangles in the field of view
				#
				calc_az, calc_east, calc_south = where.where( targets )

				for tgt in targets:
                                        header.append( "left (rad)" )
                                        csv.append( tgt.left_rad )
                                        header.append( "rght (rad)" )
                                        csv.append( tgt.right_rad )
                                        header.append( "top  (rad)" )
                                        csv.append( tgt.top_rad )
                                        header.append( "bot  (rad)" )
                                        csv.append( tgt.bottom_rad )
                                        header.append( "ctr-az-rad" )
                                        csv.append( tgt.azimuth_rad )
                                        header.append( "ctr-el-rad" )
                                        csv.append( tgt.elevation_rad )
                                        header.append( "d_est_1-in" )
                                        csv.append( tgt.dist_est_1 )
                                        header.append( "h_est_1-in" )
                                        csv.append( tgt.height_est_1 )
                                        header.append( "level     " )
                                        csv.append( target_name[tgt.level] )
                                        header.append( "position  " )
                                        csv.append( target_name[tgt.pos] )

                                for i in range( len(targets), 4 ):
                                        header.append( "left (rad)" )
                                        csv.append( "NaN" )
                                        header.append( "rght (rad)" )
                                        csv.append( "NaN" )
                                        header.append( "top  (rad)" )
                                        csv.append( "NaN" )
                                        header.append( "bot  (rad)" )
                                        csv.append( "NaN" )
                                        header.append( "ctr-az-rad" )
                                        csv.append( "NaN" )
                                        header.append( "ctr-el-rad" )
                                        csv.append( "NaN" )
                                        header.append( "d_est_1-in" )
                                        csv.append( "NaN" )
                                        header.append( "h_est_1-in" )
                                        csv.append( "NaN" )
                                        header.append( "level     " )
                                        csv.append( target_name[where.UNKNOWN] )
                                        header.append( "position  " )
                                        csv.append( target_name[where.UNKNOWN] )

                                header.append( "leftmost  " )
                                csv.append( where.leftmost )
                                header.append( "rightmost " )
                                csv.append( where.rightmost )
                                header.append( "south1    " )
                                csv.append( where.south1 )
                                header.append( "east1     " )
                                csv.append( where.east1 )
                                header.append( "az1       " )
                                csv.append( where.az1 )
                                header.append( "south2    " )
                                csv.append( where.south2 )
                                header.append( "east2" )
                                csv.append( where.east2 )
                                header.append( "az2       " )
                                csv.append( where.az2 )
                                header.append( "south     " )
                                csv.append( calc_south )
                                header.append( "east      " )
                                csv.append( calc_east )
                                header.append( "az        " )
                                csv.append( calc_az )


				# calc_south = -1000 if we did not find two targets in the field of view
				#
				# if we found at least 2 targets in the camera field of view
				if calc_south != -1000 :
					debug_pos_err = 'heading-err={0:6.1f}(deg) east-err={1:6.1f}(in) south-err={2:6.1f}(in)'.format(
						az-math.degrees(calc_az), calc_east-east, calc_south - south)
					#
					# Find the target we were aiming at in this test case
					for r in targets:
                                           if r.pos == t :
						   #
						   # Perform step 13
						   # Calculate the azimuth offset from the center of the backboard to the
						   # center of the hoop
						   calc_target_az, calc_az_offset = where.target_backboard_az_and_az_offset( 
							   r, calc_east, calc_south )
                                                   header.append( "az-off-rad" )
                                                   csv.append( calc_az_offset )

						   #
						   # Perform step 14
						   # Calculate the range from the camera to the center of the hoop
						   calc_target_range              = where.target_range( r, calc_east, calc_south )
                                                   header.append( "range (in)" )
                                                   csv.append( calc_target_range )

						   #
						   # Calculate the actual (ideal) azimuth offset and range assuming
						   # that we had no errors calculating where we were at and calculating
						   # our heading
						   #
						   actual_target_az, az_offset    = where.target_backboard_az_and_az_offset( 
							   r, east, south )
						   actual_target_range            = where.target_range( r, east, south)

						   #
						   # Accumulate Root Mean Square (RMS) Heading and Range for this test run
						   #
						   cnt = cnt + 1						   
						   rms_clc_a_err = rms_clc_a_err + math.pow( calc_az_offset-az_offset,2 )
						   rms_clc_r_err = rms_clc_a_err + math.pow( calc_target_range-actual_target_range,2 )

						   print '{0:s} {1:s} in-view:{2:s} target:{3:s} az-err-to-hoop={4:4.1f}(deg) range-err-to-hoop={5:4.1f}(in)'.format(
							debug_label, debug_pos_err, where.debug_found, target_name[r.pos], 
							math.degrees(calc_az_offset-az_offset), calc_target_range - actual_target_range)
                                                   if printedHeader == 0:
                                                       comma = ''
                                                       for i in header:
                                                           f_csv.write( '{0:s}{1:>15s}'.format( comma, i ) )
                                                           comma = ','
                                                       printedHeader = 1
                                                       f_csv.write( "\n" )
                                                   comma = ''
                                                   for i in csv:
                                                       if type(i) == str:
                                                           f_csv.write( '{0:s}{1:>15s}'.format( comma, i ) )
                                                       if type(i) == int:
                                                           f_csv.write( '{0:s}{1:>15d}'.format( comma, i ) )
                                                       if type(i) == float:
                                                           f_csv.write( '{0:s}{1:>15f}'.format( comma, i ) )
                                                       comma = ','
                                                   f_csv.write( "\n" )

				else:
					debug_pos_err = '---------------------------------------'

	#
	# Print the RMS errors
	#
	print 'rms_clc_r_err={0:10.7f} rms_clc_a_err={1:10.7f}'.format( math.sqrt(rms_clc_r_err/cnt), math.degrees(math.sqrt(rms_clc_a_err/cnt)) ) 
        f_csv.close()