- Notifications
You must be signed in to change notification settings - Fork910
Open
Labels

Description
Python kernel keeps getting dead.
When I open the CV2 feed. It keeps getting crashed (not responding window).
Inthiscode :cap=cv2.VideoCapture(0)# Set mediapipe modelwithmp_holistic.Holistic(min_detection_confidence=0.5,min_tracking_confidence=0.5)asholistic:whilecap.isOpened():# Read feedret,frame=cap.read()# Make detectionsimage,results=mediapipe_detection(frame,holistic)print(results)# Draw landmarksdraw_styled_landmarks(image,results)# Show to screencv2.imshow('OpenCV Feed',image)# Break gracefullyifcv2.waitKey(10)&0xFF==ord('q'):breakcap.release()cv2.destroyAllWindows()```->It'sworkingfinebutinthiscode:```pythoncap=cv2.VideoCapture(0)withmp_holistic.Holistic(min_detection_confidence=0.5,min_tracking_confidence=0.5)asholistic:foractioninactions:forsequenceinrange(start_folder,start_folder+no_sequences):forframe_numinrange(sequence_length):ret,frame=cap.read()image,results=mediapipe_detection(frame,holistic)draw_styled_landmarks(image,results)ifframe_num==0:cv2.putText(image,'STARTING COLLECTION', (120,200),cv2.FONT_HERSHEY_SIMPLEX,1, (0,255,0),4,cv2.LINE_AA)cv2.putText(image,'Collecting frames for {} Video Number {}'.format(action,sequence), (15,12),cv2.FONT_HERSHEY_SIMPLEX,0.5, (0,0,255),1,cv2.LINE_AA)cv2.imshow('OpenCV Feed',image)cv2.waitKey(500)else:cv2.putText(image,'Collecting frames for {} Video Number {}'.format(action,sequence), (15,12),cv2.FONT_HERSHEY_SIMPLEX,0.5, (0,0,255),1,cv2.LINE_AA)cv2.imshow('OpenCV Feed',image)keypoints=extract_keypoints(results)npy_path=os.path.join(DATA_PATH,action,str(sequence),str(frame_num))np.save(npy_path,keypoints)ifcv2.waitKey(10)&0xFF==ord('q'):breakcap.release()cv2.destroyAllWindows()
It's getting crashed.
It just open the CV2 feed window and freeze.
This code worked just fine a month ago.
I'm using Python 3.11.5 because it's the highest version that is compatible with TensorFlow.
I updated all the outdated library.
Use the environment approach.
While running my task manager show python task for few second.
There is no change in CPU usage, but memory usage increases by 900 MB to 1 GB.
I don't know what causes the problem?
Tried updating BIOS,system, libraries, pip, environment approach.
I also use cv2 windowthread method.