MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / detect_windows

Method detect_windows

rtpose_wrapper/python/caffe/detector.py:56–99  ·  view source on GitHub ↗

Do windowed detection over given images and windows. Windows are extracted then warped to the input dimensions of the net. Parameters ---------- images_windows: (image filename, window list) iterable. context_crop: size of context border to crop in p

(self, images_windows)

Source from the content-addressed store, hash-verified

54 self.configure_crop(context_pad)
55
56 def detect_windows(self, images_windows):
57 """
58 Do windowed detection over given images and windows. Windows are
59 extracted then warped to the input dimensions of the net.
60
61 Parameters
62 ----------
63 images_windows: (image filename, window list) iterable.
64 context_crop: size of context border to crop in pixels.
65
66 Returns
67 -------
68 detections: list of {filename: image filename, window: crop coordinates,
69 predictions: prediction vector} dicts.
70 """
71 # Extract windows.
72 window_inputs = []
73 for image_fname, windows in images_windows:
74 image = caffe.io.load_image(image_fname).astype(np.float32)
75 for window in windows:
76 window_inputs.append(self.crop(image, window))
77
78 # Run through the net (warping windows to input dimensions).
79 in_ = self.inputs[0]
80 caffe_in = np.zeros((len(window_inputs), window_inputs[0].shape[2])
81 + self.blobs[in_].data.shape[2:],
82 dtype=np.float32)
83 for ix, window_in in enumerate(window_inputs):
84 caffe_in[ix] = self.transformer.preprocess(in_, window_in)
85 out = self.forward_all(**{in_: caffe_in})
86 predictions = out[self.outputs[0]]
87
88 # Package predictions with images and windows.
89 detections = []
90 ix = 0
91 for image_fname, windows in images_windows:
92 for window in windows:
93 detections.append({
94 'window': window,
95 'prediction': predictions[ix],
96 'filename': image_fname
97 })
98 ix += 1
99 return detections
100
101 def detect_selective_search(self, image_fnames):
102 """

Callers 2

mainFunction · 0.95

Calls 2

cropMethod · 0.95
preprocessMethod · 0.45

Tested by

no test coverage detected