[問題] Python語法問題請益
小弟最近在學Python,
實際應用需要修改網上的範例,
其中看到一段程式碼無法理解,
希望板上先進能協助,謝謝。
detections = []
detections = [Detection(bbox, score, feature) for bbox,score, feature in
zip(detections, track_scores, features)]
1.detections List的第一個元素中有for,後面帶有bbox,score,
不曉得這是什麼意思@@?
實際在跑偵錯模式時,此行程式碼會進入數次。這個for
2.第二個元素中.. feature in這是什麼意思呢?
謝謝。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.230.200.240
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1556733983.A.566.html
→
05/02 02:11,
6年前
, 1F
05/02 02:11, 1F
→
05/02 02:12,
6年前
, 2F
05/02 02:12, 2F
→
05/02 02:12,
6年前
, 3F
05/02 02:12, 3F
→
05/02 02:12,
6年前
, 4F
05/02 02:12, 4F
→
05/02 02:30,
6年前
, 5F
05/02 02:30, 5F
另有一個問題想請問,某段程式呼叫了_match函式,追蹤到_match後,
發現裡面又定義了一個函式,而這些函式參數完全不曉得是哪裡來的@@
_match只有detections這個引數阿...
再麻煩板友解惑,謝謝了..
def _match(self, detections):
def gated_metric(tracks, dets, track_indices, detection_indices):
features = np.array([dets[i].feature for i in detection_indices])
targets = np.array([tracks[i].track_id for i in track_indices])
cost_matrix = self.metric.distance(features, targets)
cost_matrix = linear_assignment.gate_cost_matrix(
self.kf, cost_matrix, tracks, dets, track_indices,
detection_indices)
return cost_matrix
# Split track set into confirmed and unconfirmed tracks.
confirmed_tracks = [
i for i, t in enumerate(self.tracks) if t.is_confirmed()]
unconfirmed_tracks = [
i for i, t in enumerate(self.tracks) if not t.is_confirmed()]
※ 編輯: james999 (36.230.200.240), 05/02/2019 02:33:36
推
05/02 02:57,
6年前
, 6F
05/02 02:57, 6F
→
05/02 16:21,
6年前
, 7F
05/02 16:21, 7F
Python 近期熱門文章
PTT數位生活區 即時熱門文章