Closed yoyojacky closed 2 years ago
Hi @yoyojacky, Are you able to execute the code and see the result and Does that cause code breakage ? Python threading and glog logging did actually work ?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.
Closing as stale. Please reopen if you'd like to work on this further.
Hi @yoyojacky, Are you able to execute the code and see the result and Does that cause code breakage ? Python threading and glog logging did actually work ?
Hi sgowroji,
I found that it maybe the OS archteture issue, I am running an 64bit aarm64 OS which is downdload from here: https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2022-01-28/
and i am create the virual environment by using virualenv
and install the package via pip3 install mediapipe-rpi4
and using the same code from the mediapipe website and no luck, it will not work properly ,but openCV works fine.
I had the same issue and I found that:
Your problem is Memory. You are using your full memory.
Creating objects inside a loop.
As a lazy python developer I always thought when a variable is overwritten the __del__
method will work and it will be garbage collected.
it's not the case. del
does not free the memory. It only informs that you are no longer in need of the memory. See: https://stackoverflow.com/a/35121781
In your code here:
hands = mp_hands.Hands(min_detection_confidence=0.5, min_tracking_confidence=0.5)
you are creating a Hands
object over and over. And according to the information given above you are not freeing memory by overriding the variable.
You may need to move the line before the loop as such:
import cv2
import mediapipe as mp
mp_draw = mp.solutions.drawing_utils
mp_hands = mp.solutions.hands
cap = cv2.VideoCapture(0)
hands = mp_hands.Hands(min_detection_confidence=0.5, min_tracking_confidence=0.5)
while True:
ret, frame = cap.read()
frame = cv2.flip(frame, 1)
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame_rgb.flags.writeable = False
result = hands.process(frame_rgb)
frame_rgb.flags.writeable = True
frame = cv2.cvtColor(frame_rgb, cv2.COLOR_RGB2BGR)
if result.multi_hand_landmarks:
for lms in result.multi_hand_landmarks:
mp_draw.draw_landmarks(frame, lms, mp_hands.HAND_CONNECTIONS,
mp_draw.DrawingSpec(color=(255, 0, 255),thickness=5, circle_radius=5))
mp_draw.draw_landmarks(frame, lms, mp_hands.HAND_CONNECTIONS, connection_drawing_spec=mp_draw.DrawingSpec((0, 255, 0), thickness=5, circle_radius=4))
cv2.imshow("junction2021", frame)
if cv2.waitKey(1) & 0xFF == 27:
break
cap.release()
cv2.destroyAllWindows()
it will work perfectly.
Current incranation of the the same title description now at https://github.com/google/mediapipe/issues/5371
Please make sure that this is a bug and also refer to the troubleshooting, FAQ documentation before raising any issues.
System information
mp_draw = mp.solutions.drawing_utils mp_hands = mp.solutions.hands
cap = cv2.VideoCapture(0)
while True: ret, frame = cap.read() frame = cv2.flip(frame, 1) frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
cap.release() cv2.destroyAllWindows()
WARNING: Logging before InitGoogleLogging() is written to STDERR F20211124 01:37:01.669302 261254656 threadpool_pthread_impl.cc:51] Check failed: res == 0 (35 vs. 0) pthread_create failed Check failure stack trace: