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

WARNING: Logging before InitGoogleLogging() is written to STDERR #2810

Closed
yoyojacky opened this issue Nov 23, 2021 · 7 comments
Closed

WARNING: Logging before InitGoogleLogging() is written to STDERR #2810

yoyojacky opened this issue Nov 23, 2021 · 7 comments
Assignees
Labels
legacy:hands Hand tracking/gestures/etc platform:python MediaPipe Python issues platform:raspberry pi Raspberry pi ARM type:support General questions

Comments

@yoyojacky
Copy link

Please make sure that this is a bug and also refer to the troubleshooting, FAQ documentation before raising any issues.

System information

  • Have I written custom code (as opposed to using a stock example script provided in MediaPipe):
import cv2
import mediapipe as mp

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)

    hands = mp_hands.Hands(min_detection_confidence=0.5, min_tracking_confidence=0.5)
    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()
  • OS Platform and Distribution ( MacOS 11.6.1):
  • Programming Language and version ( Python3.8):
  • MediaPipe version:
  • Solution ( Hands ):

Standalone code to reproduce the issue:

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: ***

It also appears in my Raspberry Pi 4B too, with the same code and mediapipe version in Raspberry Pi 4b is mediapipe-rpi4.

@yoyojacky yoyojacky added the type:support General questions label Nov 23, 2021
@sgowroji sgowroji added platform:python MediaPipe Python issues platform:raspberry pi Raspberry pi ARM legacy:hands Hand tracking/gestures/etc stat:awaiting response Waiting for user response stat:awaiting googler Waiting for Google Engineer's Response and removed stat:awaiting response Waiting for user response labels Nov 25, 2021
@sgowroji sgowroji assigned jiuqiant and unassigned sgowroji Nov 25, 2021
@sgowroji
Copy link

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 ?

@sgowroji sgowroji added stat:awaiting response Waiting for user response and removed stat:awaiting googler Waiting for Google Engineer's Response labels Dec 16, 2021
@google-ml-butler
Copy link

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.

@google-ml-butler
Copy link

Closing as stale. Please reopen if you'd like to work on this further.

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@sgowroji sgowroji removed stat:awaiting response Waiting for user response stale labels Jan 3, 2022
@yoyojacky
Copy link
Author

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.

@mshemuni
Copy link

mshemuni commented Jul 13, 2022

I had the same issue and I found that:

The problem

Your problem is Memory. You are using your full memory.

Why?

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.

Solution

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.

@matanox
Copy link

matanox commented May 2, 2024

Current incranation of the the same title description now at #5371

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy:hands Hand tracking/gestures/etc platform:python MediaPipe Python issues platform:raspberry pi Raspberry pi ARM type:support General questions
Projects
None yet
Development

No branches or pull requests

5 participants