This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import cv2 | |
vid = cv2.VideoCapture( 'http://<network_ip_Address>:8080/video' ) | |
st.title( 'Using Mobile Camera with Streamlit' ) | |
frame_window = st.image( [] ) | |
take_picture_button = st.button( 'Take Picture' ) | |
while True: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import cv2 | |
import numpy as np | |
import requests | |
st.title( 'Mobile Camera Preview in Streamlit' ) | |
frame_window = st.image( [] ) | |
take_picture_button = st.button( 'Take Picture' ) | |
while True: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while True: | |
# Request the image from the server | |
response = requests.get(url="http://<network_ip_address>:<port>/photo.jpg") | |
imgNp = np.array(bytearray(response.content), dtype=np.uint8) | |
frame = cv2.imdecode(imgNp, cv2.IMREAD_UNCHANGED ) | |
# As OpenCV decodes images in BGR format, we'd convert it to the RGB format | |
frame = cv2.cvtColor( frame , cv2.COLOR_BGR2RGB ) | |
frame_window.image(frame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import cv2 | |
import numpy as np | |
import requests | |
# Title of the app | |
st.title( 'Mobile Camera Preview in Streamlit' ) | |
# An empty image container that will hold the frames we'll fetch from the server | |
frame_window = st.image( [] ) |
- Kernels: Everything You Need to Know
- Principal Component Analysis: Everything You Need To Know
- Demystifying Monte Carlo Integration
- Demystifying Linear Independence
- Demystifying Probability Distributions ( 1 / 3 )
- Demystifying Probability Distributions ( 2 / 3 )
- [Demystifying Probability Distributions ( 3 / 3 )](https://www.canto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
a = 0 | |
b = 1 | |
N = 1000 | |
def f( x ): | |
return 2 * x**5 | |
def uniform(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ML Model to detect the age of a person, hosted on Heroku | |
class AgeDetectionModel { | |
private val herokuModelPredictURL = "https://age-detection-tf-app.herokuapp.com/predict" | |
private val mediaType = "application/json".toMediaType() | |
private val okHttpClient = OkHttpClient() | |
interface PredictionCallback { | |
fun onResult( age : Int ) | |
fun onError( error : String ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Detect faces in the given image and crop them. | |
// Pass the cropped faces to the AgeDetectionModel | |
private fun detectFaces(image: Bitmap) { | |
val inputImage = InputImage.fromBitmap(image, 0) | |
firebaseFaceDetector.process(inputImage) | |
.addOnSuccessListener { faces -> | |
if ( faces.size != 0 ) { | |
progressDialog.apply { | |
dismiss() | |
setMessage( "📍 Posting to server ...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
implementation 'androidx.core:core-ktx:1.7.0' | |
implementation 'androidx.appcompat:appcompat:1.4.1' | |
implementation 'com.google.android.material:material:1.5.0' | |
implementation 'androidx.constraintlayout:constraintlayout:2.1.3' | |
// 1. MLKit Face Detection | |
implementation 'com.google.android.gms:play-services-mlkit-face-detection:17.0.0' | |
// 2. OkHttp is a HTTP client for Android |
NewerOlder