Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'map' object is not subscriptable #8

Open
StormArcher opened this issue Dec 22, 2018 · 12 comments
Open

TypeError: 'map' object is not subscriptable #8

StormArcher opened this issue Dec 22, 2018 · 12 comments

Comments

@StormArcher
Copy link

is there any one have this problem when run the code in python3 environment ?
can you give me help to solve this problem.

@StormArcher StormArcher changed the title Traceback (most recent call last): File "run.py", line 75, in tracker.init([ix,iy,w,h], frame) File "/home/hp/zjc/nk_PyCharm/PyCharm_project/nk_KCF/3_uoip-KCFpy /KCFpy/kcftracker.py", line 269, in init self._tmpl = self.getFeatures(image, 1) File "/home/hp/zjc/nk_PyCharm/PyCharm_project/nk_KCF/3_uoip-KCFpy /KCFpy/kcftracker.py", line 185, in getFeatures cx = self._roi[0] + self._roi[2]/2 #float TypeError: 'map' object is not subscriptable /KCFpy/kcftracker.py", line 194, in getFeatures cx = self._roi[0] + self._roi[2]/2 # float # TODO 此处报错 TypeError: 'map' object is not subscriptable Dec 22, 2018
@StormArcher
Copy link
Author

$ python run.py
Traceback (most recent call last):
File "run.py", line 79, in
tracker.init([ix, iy, w, h], frame) # TODO tracker.init
File "/home/hp/zjc/nk_PyCharm/PyCharm_project/nk_DeepSortYolo/deep_sort_yolov3-master/3_uoip-KCFpy
/KCFpy/kcftracker.py", line 283, in init
self._tmpl = self.getFeatures(image, 1)
File "/home/hp/zjc/nk_PyCharm/PyCharm_project/nk_DeepSortYolo/deep_sort_yolov3-master/3_uoip-KCFpy
/KCFpy/kcftracker.py", line 194, in getFeatures
cx = self._roi[0] + self._roi[2]/2 # float # TODO 此处报错
TypeError: 'map' object is not subscriptable

@StormArcher StormArcher changed the title /KCFpy/kcftracker.py", line 194, in getFeatures cx = self._roi[0] + self._roi[2]/2 # float # TODO 此处报错 TypeError: 'map' object is not subscriptable TypeError: 'map' object is not subscriptable Dec 22, 2018
@Dai-z
Copy link

Dai-z commented Dec 27, 2018

$ python run.py
Traceback (most recent call last):
File "run.py", line 79, in
tracker.init([ix, iy, w, h], frame) # TODO tracker.init
File "/home/hp/zjc/nk_PyCharm/PyCharm_project/nk_DeepSortYolo/deep_sort_yolov3-master/3_uoip-KCFpy
/KCFpy/kcftracker.py", line 283, in init
self._tmpl = self.getFeatures(image, 1)
File "/home/hp/zjc/nk_PyCharm/PyCharm_project/nk_DeepSortYolo/deep_sort_yolov3-master/3_uoip-KCFpy
/KCFpy/kcftracker.py", line 194, in getFeatures
cx = self._roi[0] + self._roi[2]/2 # float # TODO 此处报错
TypeError: 'map' object is not subscriptable

map() returns a list in python2, but in python3, it returns a map object.
So you can wrap map() with list() e.g.

list(map(float, roi))

And i guess you'll meet other errors with python3 like: '/' may return a int in python2 if two numbers are both int, but always return float in python3.

After solving all these errors with python3, I can run this code, but sometimes I crop a region, it will crash, like this:
image
Do you know anything about this?

@StormArcher
Copy link
Author

Thanks i already use list map.your advice is good .i meet many problem .now i can run . I am in china . It is to late .tomorrow i will see the problem you put deeper

@StormArcher
Copy link
Author

when you crop a region. It.must be even pixel .if it's odd pixel,will meet this problem. raw an col both need even .i solve the problem by turning odd to even. I hope it can help you .if you have other better method please share it with me

@Dai-z
Copy link

Dai-z commented Dec 28, 2018

Thanks! It won't crash now

@StormArcher
Copy link
Author

Do you. Use the method i provide to. Solve your problem ? i think there is other better way to solve it

@raozhongyu
Copy link

你好,我想问一下添加list 之后是否出现
Traceback (most recent call last):
File "/home/rao/KCFpy/run.py", line 75, in
tracker.init([ix,iy,w,h], frame)
File "/home/rao/KCFpy/kcftracker.py", line 271, in init
self._tmpl = self.getFeatures(image, 1)
File "/home/rao/KCFpy/kcftracker.py", line 220, in getFeatures
z = cv2.resize(z, tuple(self._tmpl_sz))
TypeError: integer argument expected, got float
这种问题

@irisqp
Copy link

irisqp commented Feb 17, 2019

ink there is other better way to solve it
你好,我也遇到了这个问题,请问你具体是怎么改的呢?even pixel怎么确定,还有就是,我怎么能暂停视频,画好我要追踪的目标,然后再追踪呢,视频里的目标移动太快了,我来不及画框。

@irisqp
Copy link

irisqp commented Feb 17, 2019

你好,我想问一下添加list 之后是否出现
Traceback (most recent call last):
File "/home/rao/KCFpy/run.py", line 75, in
tracker.init([ix,iy,w,h], frame)
File "/home/rao/KCFpy/kcftracker.py", line 271, in init
self._tmpl = self.getFeatures(image, 1)
File "/home/rao/KCFpy/kcftracker.py", line 220, in getFeatures
z = cv2.resize(z, tuple(self._tmpl_sz))
TypeError: integer argument expected, got float
这种问题

是,我把float转为int后还会报新的错误

@thenighthunter0
Copy link

然后,你们怎么解决的呢

@HIT-five
Copy link

然后,你们怎么解决的呢

change all the '/' into '//' in these codes

@GreenTeaHua
Copy link

in line #267
self._roi = list(map(float, roi)) # add list by hua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants