Skip to content

Instantly share code, notes, and snippets.

View shubham0204's full-sized avatar
🎯
Focusing

Shubham Panchal shubham0204

🎯
Focusing
View GitHub Profile

Address

Address Area

Address Building

Address City

Address Country

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:
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:
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)
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( [] )
import random
a = 0
b = 1
N = 1000
def f( x ):
return 2 * x**5
def uniform():
// 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 )
// 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 ...")