Esempio n. 1
0
def extract_features_hahog(image, config):
    t = time.time()
    points, desc = csfm.hahog(
        image.astype(np.float32) /
        255,  # VlFeat expects pixel values between 0, 1
        peak_threshold=config.get('hahog_peak_threshold', 0.003),
        edge_threshold=config.get('hahog_edge_threshold', 10))
    print 'Found {0} points in {1}s'.format(len(points), time.time() - t)
    if config.get('feature_root', False): desc = root_feature(desc)
    return mask_and_normalize_features(points, desc, image.shape[1],
                                       image.shape[0], config)
Esempio n. 2
0
def extract_features_hahog(image, config):
    t = time.time()
    points, desc = csfm.hahog(image.astype(np.float32) / 255, # VlFeat expects pixel values between 0, 1
                              peak_threshold = config.get('hahog_peak_threshold', 0.003),
                              edge_threshold = config.get('hahog_edge_threshold', 10),
                              target_num_features = config.get('feature_min_frames', 0),
                              use_adaptive_suppression = config.get('feature_use_adaptive_suppression', False))

    if config.get('feature_root', False):
        desc = np.sqrt(desc)
        uchar_scaling = 362  # x * 512 < 256  =>  sqrt(x) * 362 < 256
    else:
        uchar_scaling = 512

    if config.get('hahog_normalize_to_uchar', False):
        desc = (uchar_scaling * desc).clip(0, 255).round()

    logger.debug('Found {0} points in {1}s'.format( len(points), time.time()-t ))
    return points, desc
Esempio n. 3
0
def extract_features_hahog(image, config):
    t = time.time()
    points, desc = csfm.hahog(image.astype(np.float32) / 255, # VlFeat expects pixel values between 0, 1
                              peak_threshold = config.get('hahog_peak_threshold', 0.003),
                              edge_threshold = config.get('hahog_edge_threshold', 10),
                              target_num_features = config.get('feature_min_frames', 0),
                              use_adaptive_suppression = config.get('feature_use_adaptive_suppression', False))

    if config.get('feature_root', False):
        desc = np.sqrt(desc)
        uchar_scaling = 362  # x * 512 < 256  =>  sqrt(x) * 362 < 256
    else:
        uchar_scaling = 512

    if config.get('hahog_normalize_to_uchar', False):
        desc = (uchar_scaling * desc).clip(0, 255).round()

    print 'Found {0} points in {1}s'.format( len(points), time.time()-t )
    return points, desc
Esempio n. 4
0
import cv2
import csfm
import numpy as np

image = cv2.imread("test.png", cv2.CV_LOAD_IMAGE_COLOR)
img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
points, desc = csfm.hahog(img.astype(np.float32) / 255, 0, False, True)

imgFloat = img.astype(np.float32) / 255
for x in imgFloat[0, 0:10]:
    print "{:10.4f}".format(x)

points, desc = csfm.hahog(img.astype(np.float32) / 255, 0.01, 10, 0, False, True)

cv.imshow("dst_rt", img)
cv.waitKey(0)
cv.destroyAllWindows()