Let's Fill the gap between Emotions and TEchnical Field, by EMSR. Open to Contribute; Free to Use (Creatibve Commons); Currently under Construction. Developed by SUKH, (c) 2023.
, or preview Presentation from Here
First things First; Fork This Repo in order to getting started.
[preview] Command to add Emottions:-
elif(emotion == "[emotional_state]"):
[Action]
Making users upload files or Capturing images directly from User's Webcam, By using JS in Python, As follows:
import imutils
import numpy as np
import cv2
from google.colab.patches import cv2_imshow
from IPython.display import display, Javascript
from google.colab.output import eval_js
from base64 import b64decode
def take_photo(filename='[path]', quality=0.8):
js = Javascript('''
async function takePhoto(quality) {
const div = document.createElement('div');
const capture = document.createElement('button');
capture.textContent = 'Capture';
div.appendChild(capture);
const video = document.createElement('video');
video.style.display = 'block';
const stream = await navigator.mediaDevices.getUserMedia({video: true});
document.body.appendChild(div);
div.appendChild(video);
video.srcObject = stream;
await video.play();
// Resize the output to fit the video element.
google.colab.output.setIframeHeight(document.documentElement.scrollHeight, true);
// Wait for Capture to be clicked.
await new Promise((resolve) => capture.onclick = resolve);
const canvas = document.createElement('canvas');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0);
stream.getVideoTracks()[0].stop();
div.remove();
return canvas.toDataURL('[path]', quality);
}
''')
display(js)
data = eval_js('takePhoto({})'.format(quality))
binary = b64decode(data.split(',')[1])
with open(filename, 'wb') as f:
f.write(binary)
return filename
if you are using Google colab, then firstly import drive
from google.colab import drive
drive.mount('/content/drive')
now getting user's pic fronm Camera/webcam
image_file = take_photo()
Make sure to modify locations, highlighted follows:
Now use this in Your Project Fully freely!
Copyright (c) 2023, By SUKH. All Rights Reserved.