Description stringlengths 9 105 | Link stringlengths 45 135 | Code stringlengths 10 26.8k | Test_Case stringlengths 9 202 | Merge stringlengths 63 27k |
|---|---|---|---|---|
White and black dot detection | https://www.geeksforgeeks.org/white-and-black-dot-detection-using-opencv-python/ | import cv2 |
#Output : 23 | White and black dot detection
import cv2
#Output : 23
[END] |
White and black dot detection | https://www.geeksforgeeks.org/white-and-black-dot-detection-using-opencv-python/ | # path ="C:/Users/Personal/Downloads/black dot.jpg"
path = "black dot.jpg" |
#Output : 23 | White and black dot detection
# path ="C:/Users/Personal/Downloads/black dot.jpg"
path = "black dot.jpg"
#Output : 23
[END] |
White and black dot detection | https://www.geeksforgeeks.org/white-and-black-dot-detection-using-opencv-python/ | gray = cv2.imread(path, 0) |
#Output : 23 | White and black dot detection
gray = cv2.imread(path, 0)
#Output : 23
[END] |
White and black dot detection | https://www.geeksforgeeks.org/white-and-black-dot-detection-using-opencv-python/ | # threshold
th, threshed = cv2.threshold(gray, 100, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU) |
#Output : 23 | White and black dot detection
# threshold
th, threshed = cv2.threshold(gray, 100, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)
#Output : 23
[END] |
White and black dot detection | https://www.geeksforgeeks.org/white-and-black-dot-detection-using-opencv-python/ | # findcontours
cnts = cv2.findContours(threshed, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[-2] |
#Output : 23 | White and black dot detection
# findcontours
cnts = cv2.findContours(threshed, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[-2]
#Output : 23
[END] |
White and black dot detection | https://www.geeksforgeeks.org/white-and-black-dot-detection-using-opencv-python/ | # filter by area
s1 = 3
s2 = 20
xcnts = []
for cnt in cnts:
if s1 < cv2.contourArea(cnt) < s2:
xcnts.append(cnt) |
#Output : 23 | White and black dot detection
# filter by area
s1 = 3
s2 = 20
xcnts = []
for cnt in cnts:
if s1 < cv2.contourArea(cnt) < s2:
xcnts.append(cnt)
#Output : 23
[END] |
White and black dot detection | https://www.geeksforgeeks.org/white-and-black-dot-detection-using-opencv-python/ | print("\nDots number: {}".format(len(xcnts))) |
#Output : 23 | White and black dot detection
print("\nDots number: {}".format(len(xcnts)))
#Output : 23
[END] |
White and black dot detection | https://www.geeksforgeeks.org/white-and-black-dot-detection-using-opencv-python/ | import cv2
path = "white dot.png"
# reading the image in grayscale mode
gray = cv2.imread(path, 0)
# threshold
th, threshed = cv2.threshold(gray, 100, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
# findcontours
cnts = cv2.findContours(threshed, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[-2]
# filter by area
s1 = 3
s2 = ... |
#Output : 23 | White and black dot detection
import cv2
path = "white dot.png"
# reading the image in grayscale mode
gray = cv2.imread(path, 0)
# threshold
th, threshed = cv2.threshold(gray, 100, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
# findcontours
cnts = cv2.findContours(threshed, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[-2]
... |
OpenCV BGR color palette with trackbars | https://www.geeksforgeeks.org/python-opencv-bgr-color-palette-with-trackbars/ | # Python program to create RGB color
# palette with trackbars
# importing libraries
import cv2
import numpy as np
# empty function called when
# any trackbar moves
def emptyFunction():
pass
def main():
# blackwindow having 3 color chanels
image = np.zeros((512, 512, 3), np.uint8)
windowName = "Open... |
#Output : Libraries needed:
| OpenCV BGR color palette with trackbars
# Python program to create RGB color
# palette with trackbars
# importing libraries
import cv2
import numpy as np
# empty function called when
# any trackbar moves
def emptyFunction():
pass
def main():
# blackwindow having 3 color chanels
image = np.zeros((512, 5... |
Draw rectangular shape and extract objects | https://www.geeksforgeeks.org/python-draw-rectangular-shape-and-extract-objects-using-opencv/ | # Python program to extract rectangular
# Shape using OpenCV in Python3
import cv2
import numpy as np
drawing = False # true if mouse is pressed
mode = True # if True, draw rectangle.
ix, iy = -1, -1
# mouse callback function
def draw_circle(event, x, y, flags, param):
global ix, iy, drawing, mode
if even... |
#Output : python capture_events.py --image demo.jpg | Draw rectangular shape and extract objects
# Python program to extract rectangular
# Shape using OpenCV in Python3
import cv2
import numpy as np
drawing = False # true if mouse is pressed
mode = True # if True, draw rectangle.
ix, iy = -1, -1
# mouse callback function
def draw_circle(event, x, y, flags, param):
... |
Draw rectangular shape and extract objects | https://www.geeksforgeeks.org/python-draw-rectangular-shape-and-extract-objects-using-opencv/ | # Write Python code here
# import the necessary packages
import cv2
import argparse
# now let's initialize the list of reference point
ref_point = []
crop = False
def shape_selection(event, x, y, flags, param):
# grab references to the global variables
global ref_point, crop
# if the left mouse button w... |
#Output : python capture_events.py --image demo.jpg | Draw rectangular shape and extract objects
# Write Python code here
# import the necessary packages
import cv2
import argparse
# now let's initialize the list of reference point
ref_point = []
crop = False
def shape_selection(event, x, y, flags, param):
# grab references to the global variables
global ref_po... |
Drawing with Mouse on Images using Python-OpenCV | https://www.geeksforgeeks.org/drawing-with-mouse-on-images-using-python-opencv/ | import cv2
img = cv2.imread("flower.jpg")
def draw_circle(event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONDOWN:
print("hello")
cv2.circle(img, (x, y), 100, (0, 255, 0), -1)
cv2.namedWindow(winname="Title of Popup Window")
cv2.setMouseCallback("Title of Popup Window", draw_circle)
whi... |
#Output : cv2.namedWindow("Title of Popup Window")
| Drawing with Mouse on Images using Python-OpenCV
import cv2
img = cv2.imread("flower.jpg")
def draw_circle(event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONDOWN:
print("hello")
cv2.circle(img, (x, y), 100, (0, 255, 0), -1)
cv2.namedWindow(winname="Title of Popup Window")
cv2.setMouseCa... |
Drawing with Mouse on Images using Python-OpenCV | https://www.geeksforgeeks.org/drawing-with-mouse-on-images-using-python-opencv/ | import cv2
img = cv2.imread("flower.jpg")
# variables
ix = -1
iy = -1
drawing = False
def draw_rectangle_with_drag(event, x, y, flags, param):
global ix, iy, drawing, img
if event == cv2.EVENT_LBUTTONDOWN:
drawing = True
ix = x
iy = y
elif event == cv2.EVENT_MOUSEMOVE:
... |
#Output : cv2.namedWindow("Title of Popup Window")
| Drawing with Mouse on Images using Python-OpenCV
import cv2
img = cv2.imread("flower.jpg")
# variables
ix = -1
iy = -1
drawing = False
def draw_rectangle_with_drag(event, x, y, flags, param):
global ix, iy, drawing, img
if event == cv2.EVENT_LBUTTONDOWN:
drawing = True
ix = x
iy = ... |
Text Detection and Extraction using OpenCV and OCR | https://www.geeksforgeeks.org/text-detection-and-extraction-using-opencv-and-ocr/ | # Import required packages
import cv2
import pytesseract
# Mention the installed location of Tesseract-OCR in your system
pytesseract.pytesseract.tesseract_cmd = "System_path_to_tesseract.exe"
# Read image from which text needs to be extracted
img = cv2.imread("sample.jpg")
# Preprocessing the image starts
# Conver... |
#Output : pip install opencv-python | Text Detection and Extraction using OpenCV and OCR
# Import required packages
import cv2
import pytesseract
# Mention the installed location of Tesseract-OCR in your system
pytesseract.pytesseract.tesseract_cmd = "System_path_to_tesseract.exe"
# Read image from which text needs to be extracted
img = cv2.imread("sampl... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | """
The ResizeUtils provides resizing function
to keep the aspect ratio intact
Credits: AndyP at StackOverflow"""
class ResizeUtils:
# Given a target height, adjust the image
# by calculating the width and resize
def rescale_by_height(self, image, target_height, method=cv2.INTER_LANCZOS4):
... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
"""
The ResizeUtils provides resizing function
to keep the aspect ratio intact
Credits: AndyP at StackOverflow"""
class ResizeUtils:
# Given a target height, adjust the image
# by calculating the width and resize
def rescale_by_height(self, image, tar... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | # The FramesGenerator extracts image
# frames from the given video file
# The image frames are resized for
# face_recognition / dlib processing
class FramesGenerator:
def __init__(self, VideoFootageSource):
self.VideoFootageSource = VideoFootageSource
# Resize the given input to fit in a specified
... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
# The FramesGenerator extracts image
# frames from the given video file
# The image frames are resized for
# face_recognition / dlib processing
class FramesGenerator:
def __init__(self, VideoFootageSource):
self.VideoFootageSource = VideoFootageSource
# Resi... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | # Extract 1 frame from each second from video footage
# and save the frames to a specific folder
def GenerateFrames(self, OutputDirectoryName):
cap = cv2.VideoCapture(self.VideoFootageSource)
_, frame = cap.read()
fps = cap.get(cv2.CAP_PROP_FPS)
TotalFrames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
prin... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
# Extract 1 frame from each second from video footage
# and save the frames to a specific folder
def GenerateFrames(self, OutputDirectoryName):
cap = cv2.VideoCapture(self.VideoFootageSource)
_, frame = cap.read()
fps = cap.get(cv2.CAP_PROP_FPS)
TotalFrames =... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | # Following are nodes for pipeline constructions.
# It will create and asynchronously execute threads
# for reading images, extracting facial features and
# storing them independently in different threads
# Keep emitting the filenames into
# the pipeline for processing
class FramesProvider(Node):
def setup(self, ... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
# Following are nodes for pipeline constructions.
# It will create and asynchronously execute threads
# for reading images, extracting facial features and
# storing them independently in different threads
# Keep emitting the filenames into
# the pipeline for processing
clas... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | # Encode the face embedding, reference path
# and location and emit to pipeline
class FaceEncoder(Node):
def setup(self, detection_method="cnn"):
self.detection_method = detection_method
# detection_method can be cnn or hog
def run(self, data):
id = data["id"]
imagePath = data["... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
# Encode the face embedding, reference path
# and location and emit to pipeline
class FaceEncoder(Node):
def setup(self, detection_method="cnn"):
self.detection_method = detection_method
# detection_method can be cnn or hog
def run(self, data):
... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | # Receive the face embeddings for clustering and
# id for naming the distinct filename
class DatastoreManager(Node):
def setup(self, encodingsOutputPath):
self.encodingsOutputPath = encodingsOutputPath
def run(self, data):
encodings = data["encodings"]
id = data["id"]
with open(... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
# Receive the face embeddings for clustering and
# id for naming the distinct filename
class DatastoreManager(Node):
def setup(self, encodingsOutputPath):
self.encodingsOutputPath = encodingsOutputPath
def run(self, data):
encodings = data["encodings"... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | # PicklesListCollator takes multiple pickle
# files as input and merges them together
# It is made specifically to support use-case
# of merging distinct pickle files into one
class PicklesListCollator:
def __init__(self, picklesInputDirectory):
self.picklesInputDirectory = picklesInputDirectory
# Here... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
# PicklesListCollator takes multiple pickle
# files as input and merges them together
# It is made specifically to support use-case
# of merging distinct pickle files into one
class PicklesListCollator:
def __init__(self, picklesInputDirectory):
self.picklesInputD... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | # Face clustering functionality
class FaceClusterUtility:
def __init__(self, EncodingFilePath):
self.EncodingFilePath = EncodingFilePath
# Credits: Arian's pyimagesearch for the clustering code
# Here we are using the sklearn.DBSCAN functionality
# cluster all the facial embeddings to get clust... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
# Face clustering functionality
class FaceClusterUtility:
def __init__(self, EncodingFilePath):
self.EncodingFilePath = EncodingFilePath
# Credits: Arian's pyimagesearch for the clustering code
# Here we are using the sklearn.DBSCAN functionality
# cl... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | # Inherit class tqdm for visualization of progress
class TqdmUpdate(tqdm):
# This function will be passed as progress
# callback function. Setting the predefined
# variables for auto-updates in visualization
def update(self, done, total_size=None):
if total_size is not None:
self.tot... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
# Inherit class tqdm for visualization of progress
class TqdmUpdate(tqdm):
# This function will be passed as progress
# callback function. Setting the predefined
# variables for auto-updates in visualization
def update(self, done, total_size=None):
if ... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | class FaceImageGenerator:
def __init__(self, EncodingFilePath):
self.EncodingFilePath = EncodingFilePath
# Here we are creating montages for
# first 25 faces for each distinct face.
# We will also generate images for all
# the distinct faces by using the labels
# from clusters and image... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
class FaceImageGenerator:
def __init__(self, EncodingFilePath):
self.EncodingFilePath = EncodingFilePath
# Here we are creating montages for
# first 25 faces for each distinct face.
# We will also generate images for all
# the distinct faces by us... |
Unsupervised Face Clustering Pipelementsine | https://www.geeksforgeeks.org/ml-unsupervised-face-clustering-pipeline/ | # importing all classes from above Python file
from FaceClusteringLibrary import *
if __name__ == "__main__":
# Generate the frames from given video footage
framesGenerator = FramesGenerator("Footage.mp4")
framesGenerator.GenerateFrames("Frames")
# Design and run the face clustering pipeline
Curre... | Input: Footage.mp4
Output: | Unsupervised Face Clustering Pipelementsine
# importing all classes from above Python file
from FaceClusteringLibrary import *
if __name__ == "__main__":
# Generate the frames from given video footage
framesGenerator = FramesGenerator("Footage.mp4")
framesGenerator.GenerateFrames("Frames")
# Design an... |
Pedestrian Detection using OpenCV-Python | https://www.geeksforgeeks.org/pedestrian-detection-using-opencv-python/ | import cv2
import imutils
# Initializing the HOG person
# detector
hog = cv2.HOGDescriptor()
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
# Reading the Image
image = cv2.imread("img.png")
# Resizing the Image
image = imutils.resize(image, width=min(400, image.shape[1]))
# Detecting all the regio... |
#Output :
| Pedestrian Detection using OpenCV-Python
import cv2
import imutils
# Initializing the HOG person
# detector
hog = cv2.HOGDescriptor()
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
# Reading the Image
image = cv2.imread("img.png")
# Resizing the Image
image = imutils.resize(image, width=min(400, im... |
Pedestrian Detection using OpenCV-Python | https://www.geeksforgeeks.org/pedestrian-detection-using-opencv-python/ | import cv2
import imutils
# Initializing the HOG person
# detector
hog = cv2.HOGDescriptor()
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
cap = cv2.VideoCapture("vid.mp4")
while cap.isOpened():
# Reading the video stream
ret, image = cap.read()
if ret:
image = imutils.resize(i... |
#Output :
| Pedestrian Detection using OpenCV-Python
import cv2
import imutils
# Initializing the HOG person
# detector
hog = cv2.HOGDescriptor()
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
cap = cv2.VideoCapture("vid.mp4")
while cap.isOpened():
# Reading the video stream
ret, image = cap.read()
... |
Saving Operated Video from a webcam | https://www.geeksforgeeks.org/saving-operated-video-from-a-webcam-using-opencv/ | # Python program to illustrate
# saving an operated video
# organize imports
import numpy as np
import cv2
# This will return video from the first webcam on your computer.
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*"XVID")
out = cv2.VideoWriter("output... |
#Output :
| Saving Operated Video from a webcam
# Python program to illustrate
# saving an operated video
# organize imports
import numpy as np
import cv2
# This will return video from the first webcam on your computer.
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*"... |
Saving Operated Video from a webcam | https://www.geeksforgeeks.org/saving-operated-video-from-a-webcam-using-opencv/ | # Python program to illustrate
# saving an operated video
# organize imports
import numpy as np
import cv2
# This will return video from the first webcam on your computer.
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*"XVID")
out = cv2.VideoWriter("output... |
#Output :
| Saving Operated Video from a webcam
# Python program to illustrate
# saving an operated video
# organize imports
import numpy as np
import cv2
# This will return video from the first webcam on your computer.
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*"... |
Detecting objects of similar color in Python using OpenCV | https://www.geeksforgeeks.org/detecting-obects-of-similar-color-in-python-using-opencv/ | # import required library
import cv2
import numpy as np
import matplotlib.pyplot as plt
# create a video object
# for capture the frames.
# for Webcamera we pass 0
# as an argument
cap = cv2.VideoCapture(0)
# define a empty function
def nothing(x):
pass
# set window name
cv2.namedWindow("Tracking")
# Creates ... |
#Output : OpenCV
| Detecting objects of similar color in Python using OpenCV
# import required library
import cv2
import numpy as np
import matplotlib.pyplot as plt
# create a video object
# for capture the frames.
# for Webcamera we pass 0
# as an argument
cap = cv2.VideoCapture(0)
# define a empty function
def nothing(x):
pass
... |
Play a video in reverse mode | https://www.geeksforgeeks.org/python-play-video-reverse-mode-using-opencv/ | # Python program to play a video
# in reverse mode using opencv
# import cv2 library
import cv2
# videoCapture method of cv2 return video object
# Pass absolute address of video file
cap = cv2.VideoCapture("video_file_location")
# read method of video object will return
# a tuple with 1st element denotes whether
# ... |
#Output : OpenCV's application areas include :
| Play a video in reverse mode
# Python program to play a video
# in reverse mode using opencv
# import cv2 library
import cv2
# videoCapture method of cv2 return video object
# Pass absolute address of video file
cap = cv2.VideoCapture("video_file_location")
# read method of video object will return
# a tuple with 1... |
OpenCV Python program for Vehicle detection in a Video frame | https://www.geeksforgeeks.org/opencv-python-program-vehicle-detection-video-frame/ | # OpenCV Python program to detect cars in video frame# import libraries of python OpenCV??????import cv2????????????# capture frames from a videocap = cv2.VideoCapture('video.avi')????????????# Trained XML classifiers describes some features of some object we want to detectcar_cascade = cv2.CascadeClassifier('cars.xml'... |
#Output : sudo apt-get install python
| OpenCV Python program for Vehicle detection in a Video frame
# OpenCV Python program to detect cars in video frame# import libraries of python OpenCV??????import cv2????????????# capture frames from a videocap = cv2.VideoCapture('video.avi')????????????# Trained XML classifiers describes some features of some object we... |
Python - Eye blink detection project | https://www.geeksforgeeks.org/python-eye-blink-detection-project/ | # All the imports go here
import numpy as np
import cv2
# Initializing the face and eye cascade classifiers from xml files
face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
eye_cascade = cv2.CascadeClassifier("haarcascade_eye_tree_eyeglasses.xml")
# Variable store execution state
first_read ... |
#Output : The frame is captured and converted to grayscale. | Python - Eye blink detection project
# All the imports go here
import numpy as np
import cv2
# Initializing the face and eye cascade classifiers from xml files
face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
eye_cascade = cv2.CascadeClassifier("haarcascade_eye_tree_eyeglasses.xml")
# Var... |
Right and Left Hand Detection Using Python | https://www.geeksforgeeks.org/right-and-left-hand-detection-using-python/ | # Importing Libraries
import cv2
import mediapipe as mp
# Used to convert protobuf message
# to a dictionary.
from google.protobuf.json_format import MessageToDict |
#Output : pip install mediapipe
| Right and Left Hand Detection Using Python
# Importing Libraries
import cv2
import mediapipe as mp
# Used to convert protobuf message
# to a dictionary.
from google.protobuf.json_format import MessageToDict
#Output : pip install mediapipe
[END] |
Right and Left Hand Detection Using Python | https://www.geeksforgeeks.org/right-and-left-hand-detection-using-python/ | # Initializing the ModelmpHands = mp.solutions.handshands = mpHands.Hands(????????????????????????static_image_mode=False,????????????????????????model_complexity=1????????????????????????min_detection_confidence=0.75,????????????? |
#Output : pip install mediapipe
| Right and Left Hand Detection Using Python
# Initializing the ModelmpHands = mp.solutions.handshands = mpHands.Hands(????????????????????????static_image_mode=False,????????????????????????model_complexity=1????????????????????????min_detection_confidence=0.75,?????????????
#Output : pip install mediapipe
[END] |
Right and Left Hand Detection Using Python | https://www.geeksforgeeks.org/right-and-left-hand-detection-using-python/ | # Start capturing video from webcam
cap = cv2.VideoCapture(0)
while True:
# Read video frame by frame
success, img = cap.read()
# Flip the image(frame)
img = cv2.flip(img, 1)
# Convert BGR image to RGB image
imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# Process the RGB image
result... |
#Output : pip install mediapipe
| Right and Left Hand Detection Using Python
# Start capturing video from webcam
cap = cv2.VideoCapture(0)
while True:
# Read video frame by frame
success, img = cap.read()
# Flip the image(frame)
img = cv2.flip(img, 1)
# Convert BGR image to RGB image
imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2R... |
Right and Left Hand Detection Using Python | https://www.geeksforgeeks.org/right-and-left-hand-detection-using-python/ | # Importing Librariesimport cv2import mediapipe as mp????????????# Used to convert protobuf message to a dictionary.from google.protobuf.json_format import MessageToDict????????????# Initializing the ModelmpHands = mp.solutions.handshands = mpHands.Hands(????????????????????????static_image_mode=False,?????????????????... |
#Output : pip install mediapipe
| Right and Left Hand Detection Using Python
# Importing Librariesimport cv2import mediapipe as mp????????????# Used to convert protobuf message to a dictionary.from google.protobuf.json_format import MessageToDict????????????# Initializing the ModelmpHands = mp.solutions.handshands = mpHands.Hands(??????????????????????... |
Brightness Control With Hand Detection using OpenCV in Python | https://www.geeksforgeeks.org/brightness-control-with-hand-detection-using-opencv-in-python/ | # Importing Libraries
import cv2
import mediapipe as mp
from math import hypot
import screen_brightness_control as sbc
import numpy as np |
#Output : pip install mediapipe | Brightness Control With Hand Detection using OpenCV in Python
# Importing Libraries
import cv2
import mediapipe as mp
from math import hypot
import screen_brightness_control as sbc
import numpy as np
#Output : pip install mediapipe
[END] |
Brightness Control With Hand Detection using OpenCV in Python | https://www.geeksforgeeks.org/brightness-control-with-hand-detection-using-opencv-in-python/ | # Initializing the Model
mpHands = mp.solutions.hands
hands = mpHands.Hands(
static_image_mode=False,
model_complexity=1,
min_detection_confidence=0.75,
min_tracking_confidence=0.75,
max_num_hands=2,
)
Draw = mp.solutions.drawing_utils |
#Output : pip install mediapipe | Brightness Control With Hand Detection using OpenCV in Python
# Initializing the Model
mpHands = mp.solutions.hands
hands = mpHands.Hands(
static_image_mode=False,
model_complexity=1,
min_detection_confidence=0.75,
min_tracking_confidence=0.75,
max_num_hands=2,
)
Draw = mp.solutions.drawing_utils
... |
Brightness Control With Hand Detection using OpenCV in Python | https://www.geeksforgeeks.org/brightness-control-with-hand-detection-using-opencv-in-python/ | # Start capturing video from webcam
cap = cv2.VideoCapture(0)
while True:
# Read video frame by frame
_, frame = cap.read()
# Flip image
frame = cv2.flip(frame, 1)
# Convert BGR image to RGB image
frameRGB = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Process the RGB image
Process = han... |
#Output : pip install mediapipe | Brightness Control With Hand Detection using OpenCV in Python
# Start capturing video from webcam
cap = cv2.VideoCapture(0)
while True:
# Read video frame by frame
_, frame = cap.read()
# Flip image
frame = cv2.flip(frame, 1)
# Convert BGR image to RGB image
frameRGB = cv2.cvtColor(frame, cv2... |
Brightness Control With Hand Detection using OpenCV in Python | https://www.geeksforgeeks.org/brightness-control-with-hand-detection-using-opencv-in-python/ | # Importing Libraries
import cv2
import mediapipe as mp
from math import hypot
import screen_brightness_control as sbc
import numpy as np
# Initializing the Model
mpHands = mp.solutions.hands
hands = mpHands.Hands(
static_image_mode=False,
model_complexity=1,
min_detection_confidence=0.75,
min_tracking... |
#Output : pip install mediapipe | Brightness Control With Hand Detection using OpenCV in Python
# Importing Libraries
import cv2
import mediapipe as mp
from math import hypot
import screen_brightness_control as sbc
import numpy as np
# Initializing the Model
mpHands = mp.solutions.hands
hands = mpHands.Hands(
static_image_mode=False,
model_com... |
Creating a Finger Counter Using Computer Vision and OpenCV in Python | https://www.geeksforgeeks.org/creating-a-finger-counter-using-computer-vision-and-opencv-in-python/ | # import libraries and required classes
import cv2
from cvzone.HandTrackingModule import HandDetector |
#Output : pip install cvzone | Creating a Finger Counter Using Computer Vision and OpenCV in Python
# import libraries and required classes
import cv2
from cvzone.HandTrackingModule import HandDetector
#Output : pip install cvzone
[END] |
Creating a Finger Counter Using Computer Vision and OpenCV in Python | https://www.geeksforgeeks.org/creating-a-finger-counter-using-computer-vision-and-opencv-in-python/ | # declaring HandDetector with
# some basic requirements
detector = HandDetector(maxHands=1, detectionCon=0.8)
# it detect only one hand from
# video with 0.8 detection confidence
video = cv2.VideoCapture(0) |
#Output : pip install cvzone | Creating a Finger Counter Using Computer Vision and OpenCV in Python
# declaring HandDetector with
# some basic requirements
detector = HandDetector(maxHands=1, detectionCon=0.8)
# it detect only one hand from
# video with 0.8 detection confidence
video = cv2.VideoCapture(0)
#Output : pip install cvzone
[END] |
Creating a Finger Counter Using Computer Vision and OpenCV in Python | https://www.geeksforgeeks.org/creating-a-finger-counter-using-computer-vision-and-opencv-in-python/ | while True:
# Capture frame-by-frame
_, img = video.read()
img = cv2.flip(img, 1)
# Find the hand with help of detector
hand = detector.findHands(img, draw=False)
# Here we take img by default if no hand found
fing = cv2.imread("Put image path with 0 fingures up")
if hand:
# Ta... |
#Output : pip install cvzone | Creating a Finger Counter Using Computer Vision and OpenCV in Python
while True:
# Capture frame-by-frame
_, img = video.read()
img = cv2.flip(img, 1)
# Find the hand with help of detector
hand = detector.findHands(img, draw=False)
# Here we take img by default if no hand found
fing = cv2.... |
Creating a Finger Counter Using Computer Vision and OpenCV in Python | https://www.geeksforgeeks.org/creating-a-finger-counter-using-computer-vision-and-opencv-in-python/ | # Enter key 'q' to break the loop
if cv2.waitKey(1) & 0xFF == ord("q"):
break
# When everything done, release
# the capture and destroy the windows
video.release()
cv2.destroyAllWindows() |
#Output : pip install cvzone | Creating a Finger Counter Using Computer Vision and OpenCV in Python
# Enter key 'q' to break the loop
if cv2.waitKey(1) & 0xFF == ord("q"):
break
# When everything done, release
# the capture and destroy the windows
video.release()
cv2.destroyAllWindows()
#Output : pip install cvzone
[END] |
Creating a Finger Counter Using Computer Vision and OpenCV in Python | https://www.geeksforgeeks.org/creating-a-finger-counter-using-computer-vision-and-opencv-in-python/ | import cv2
from cvzone.HandTrackingModule import HandDetector
detector = HandDetector(maxHands=1, detectionCon=0.8)
video = cv2.VideoCapture(1)
while True:
_, img = video.read()
img = cv2.flip(img, 1)
hand = detector.findHands(img, draw=False)
fing = cv2.imread("Put image path with 0 fingures up")
... |
#Output : pip install cvzone | Creating a Finger Counter Using Computer Vision and OpenCV in Python
import cv2
from cvzone.HandTrackingModule import HandDetector
detector = HandDetector(maxHands=1, detectionCon=0.8)
video = cv2.VideoCapture(1)
while True:
_, img = video.read()
img = cv2.flip(img, 1)
hand = detector.findHands(img, draw=... |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
] |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"gfg_site_app.apps.GfgSiteAppConfig",
] |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"gfg_site_app.apps.GfgSiteAppConfig",
]
#Output : python3 -... |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from django.http import HttpResponse
# create a function
def geeks_view(request):
return HttpResponse("<h1>Welcome to GeeksforGeeks</h1>") |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from django.http import HttpResponse
# create a function
def geeks_view(request):
return HttpResponse("<h1>Welcome to GeeksforGeeks</h1>")
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from django.urls import path
from . import views
urlpatterns = [
path("", views.geeks_view, name="geeks_view"),
] |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from django.urls import path
from . import views
urlpatterns = [
path("", views.geeks_view, name="geeks_view"),
]
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from django.contrib import admin
from django.urls import path, include
urlpatterns = [path("admin/", admin.site.urls), path("", include("gfg_site_app.urls"))] |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from django.contrib import admin
from django.urls import path, include
urlpatterns = [path("admin/", admin.site.urls), path("", include("gfg_site_app.urls"))]
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | # import the standard Django Model
# from built-in library
from django.db import models
from datetime import datetime
class GeeksModel(models.Model):
# Field Names
title = models.CharField(max_length=200)
description = models.TextField()
created_on = models.DateTimeField(default=datetime.now)
imag... |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
# import the standard Django Model
# from built-in library
from django.db import models
from datetime import datetime
class GeeksModel(models.Model):
# Field Names
title = models.CharField(max_length=200)
description = models.TextField()
created_on = mo... |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from gfg_site_app.models import GeeksModel
obj = GeeksModel(
title="GeeksforGeeks", description="GFG is a portal for computer science students"
)
obj.save() |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from gfg_site_app.models import GeeksModel
obj = GeeksModel(
title="GeeksforGeeks", description="GFG is a portal for computer science students"
)
obj.save()
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | GeeksModel.objects.all() |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
GeeksModel.objects.all()
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | obj = GeeksModel.objects.get(id=1)
obj.title = "GFG"
obj.save()
GeeksModel.objects.all() |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
obj = GeeksModel.objects.get(id=1)
obj.title = "GFG"
obj.save()
GeeksModel.objects.all()
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | obj = GeeksModel.objects.get(id=1)
obj.delete()
GeeksModel.objects.all() |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
obj = GeeksModel.objects.get(id=1)
obj.delete()
GeeksModel.objects.all()
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | MEDIA_ROOT = BASE_DIR / "media"
MEDIA_URL = "/media/" |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
MEDIA_ROOT = BASE_DIR / "media"
MEDIA_URL = "/media/"
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from django.contrib import admin
from .models import GeeksModel
# Register your models here.
admin.site.register(
GeeksModel,
) |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from django.contrib import admin
from .models import GeeksModel
# Register your models here.
admin.site.register(
GeeksModel,
)
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
} |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | DATABASES = {??????????????????'default': {??????????????????????????????????????????'ENGINE': 'django.db.backends.postgresql',??????????????????????????????????????????'NAME': ?????????<database_name>?????????,??????????????????????????????????????????'USER': '<database_username>',????????????????????????????? |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
DATABASES = {??????????????????'default': {??????????????????????????????????????????'ENGINE': 'django.db.backends.postgresql',??????????????????????????????????????????'NAME': ?????????<database_name>?????????,??????????????????????????????????????????'USER': '<database... |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | TEMPLATES = [
{
# Template backend to be used, For example Jinja
"BACKEND": "django.template.backends.django.DjangoTemplates",
# directories for templates
"DIRS": [],
"APP_DIRS": True,
# options to configure
"OPTIONS": {
"context_processors": [
... |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
TEMPLATES = [
{
# Template backend to be used, For example Jinja
"BACKEND": "django.template.backends.django.DjangoTemplates",
# directories for templates
"DIRS": [],
"APP_DIRS": True,
# options to configure
"OP... |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
# adding the location of our templates directory
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_process... |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
# adding the location of our templates directory
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [... |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | <!DOCTYPE html><html lang="en"><head>??????????????????????"UTF-8">???????????????????"viewport" content="width=device-width, initial-scale=1.0">????????????????????????<"X-UA-Compatible" content="ie=edge">????????????????????????<title>Homepage</title></head><body>????????????????????????<h1>Welcome to |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
<!DOCTYPE html><html lang="en"><head>??????????????????????"UTF-8">???????????????????"viewport" content="width=device-width, initial-scale=1.0">????????????????????????<"X-UA-Compatible" content="ie=edge">????????????????????????<title>Homepage</title></head><body>?????... |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from django.shortcuts import render
# create a function
def geeks_view(request):
return render(request, "index.html") |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from django.shortcuts import render
# create a function
def geeks_view(request):
return render(request, "index.html")
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from django.shortcuts import render
from .models import GeeksModel
# create a function
def geeks_view(request):
content = GeeksModel.objects.all()
context = {"content": content}
return render(request, "index.html", context=context) |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from django.shortcuts import render
from .models import GeeksModel
# create a function
def geeks_view(request):
content = GeeksModel.objects.all()
context = {"content": content}
return render(request, "index.html", context=context)
#Output : python3 -m v... |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | <!DOCTYPE html><html lang="en"><head>??????????????????????"UTF-8">???????????????????"viewport" content="width=device-width, initial-scale=1.0">????????????????????????<"X-UA-Compatible" content="ie=edge">????????????????????????<title>Homepage</title></head><body>??????????????????????????????{% for data in content %... |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
<!DOCTYPE html><html lang="en"><head>??????????????????????"UTF-8">???????????????????"viewport" content="width=device-width, initial-scale=1.0">????????????????????????<"X-UA-Compatible" content="ie=edge">????????????????????????<title>Homepage</title></head><body>?????... |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | {% extends "./base2.html" %}{% extends "../base1.html" %}{% extends "./my/base3.html" %} |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
{% extends "./base2.html" %}{% extends "../base1.html" %}{% extends "./my/base3.html" %}
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from django import forms
class GeeksForm(forms.Form):
title = forms.CharField(max_length=200)
description = forms.CharField(widget=forms.Textarea)
image = forms.ImageField() |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from django import forms
class GeeksForm(forms.Form):
title = forms.CharField(max_length=200)
description = forms.CharField(widget=forms.Textarea)
image = forms.ImageField()
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from .forms import GeeksForm
def geeks_form(request):
context = {}
context["form"] = GeeksForm
return render(request, "form.html", context=context) |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from .forms import GeeksForm
def geeks_form(request):
context = {}
context["form"] = GeeksForm
return render(request, "form.html", context=context)
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from django.urls import path
from . import views
urlpatterns = [
path("", views.geeks_view, name="geeks_view"),
path("add/", views.geeks_form, name="geeks_form"),
] |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from django.urls import path
from . import views
urlpatterns = [
path("", views.geeks_view, name="geeks_view"),
path("add/", views.geeks_form, name="geeks_form"),
]
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | <form action="" method="POST">????????????????????????{% csrf_token %}????????????????????????{"submit" value="submit"></form> |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
<form action="" method="POST">????????????????????????{% csrf_token %}????????????????????????{"submit" value="submit"></form>
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | from django import forms
from .models import GeeksModel
class GeeksForm(forms.ModelForm):
class Meta:
model = GeeksModel
fields = ["title", "description", "image"] |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
from django import forms
from .models import GeeksModel
class GeeksForm(forms.ModelForm):
class Meta:
model = GeeksModel
fields = ["title", "description", "image"]
#Output : python3 -m venv ./name
[END] |
Python Web Develementsopment - Django Tutorial | https://www.geeksforgeeks.org/python-web-development-django-tutorial/ | def geeks_form(request):
if request.method == "POST":
form = GeeksForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return redirect("geeks_view")
else:
# uncomment the below line to see errors
# in the form (if any)
... |
#Output : python3 -m venv ./name | Python Web Develementsopment - Django Tutorial
def geeks_form(request):
if request.method == "POST":
form = GeeksForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return redirect("geeks_view")
else:
# uncomment the below line to see erro... |
How to Create an App in Django? | https://www.geeksforgeeks.org/how-to-create-an-app-in-django/ | # Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"projectApp",
] |
#Output : python manage.py startapp projectApp | How to Create an App in Django?
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"projectApp",
]
#Output : python manage.py startap... |
How to Create an App in Django? | https://www.geeksforgeeks.org/how-to-create-an-app-in-django/ | from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
# Enter the app name in following
# syntax for this to work
path("", include("projectApp.urls")),
] |
#Output : python manage.py startapp projectApp | How to Create an App in Django?
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
# Enter the app name in following
# syntax for this to work
path("", include("projectApp.urls")),
]
#Output : python manage.py startapp projectApp
... |
How to Create an App in Django? | https://www.geeksforgeeks.org/how-to-create-an-app-in-django/ | from django.urls import path
# now import the views.py file into this code
from . import views
urlpatterns = [path("", views.index)] |
#Output : python manage.py startapp projectApp | How to Create an App in Django?
from django.urls import path
# now import the views.py file into this code
from . import views
urlpatterns = [path("", views.index)]
#Output : python manage.py startapp projectApp
[END] |
How to Create an App in Django? | https://www.geeksforgeeks.org/how-to-create-an-app-in-django/ | from django.http import HttpResponse
def index(request):
return HttpResponse("Hello Geeks") |
#Output : python manage.py startapp projectApp | How to Create an App in Django?
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello Geeks")
#Output : python manage.py startapp projectApp
[END] |
Weather app using Django | https://www.geeksforgeeks.org/weather-app-using-django-python/ | from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("", include("main.urls")),
] |
#Output : cd weather | Weather app using Django
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("", include("main.urls")),
]
#Output : cd weather
[END] |
Weather app using Django | https://www.geeksforgeeks.org/weather-app-using-django-python/ | from django.urls import path
from . import views
urlpatterns = [
path("", views.index),
] |
#Output : cd weather | Weather app using Django
from django.urls import path
from . import views
urlpatterns = [
path("", views.index),
]
#Output : cd weather
[END] |
Weather app using Django | https://www.geeksforgeeks.org/weather-app-using-django-python/ | from django.shortcuts import render
# import json to load json data to python dictionary
import json
# urllib.request to make a request to api
import urllib.request
def index(request):
if request.method == "POST":
city = request.POST["city"]
""" api key might be expired use your own api_key
... |
#Output : cd weather | Weather app using Django
from django.shortcuts import render
# import json to load json data to python dictionary
import json
# urllib.request to make a request to api
import urllib.request
def index(request):
if request.method == "POST":
city = request.POST["city"]
""" api key might be expired ... |
Django Sign Up and login with confirmation Email | https://www.geeksforgeeks.org/django-sign-up-and-login-with-confirmation-email-python/ | from django.contrib import admin
from django.urls import path, include
from user import views as user_view
from django.contrib.auth import views as auth
urlpatterns = [
path("admin/", admin.site.urls),
##### user related path##########################
path("", include("user.urls")),
path("login/", user... |
#Output : pip install --upgrade django-crispy-forms | Django Sign Up and login with confirmation Email
from django.contrib import admin
from django.urls import path, include
from user import views as user_view
from django.contrib.auth import views as auth
urlpatterns = [
path("admin/", admin.site.urls),
##### user related path##########################
path("... |
Django Sign Up and login with confirmation Email | https://www.geeksforgeeks.org/django-sign-up-and-login-with-confirmation-email-python/ | from django.urls import path, include
from django.conf import settings
from . import views
from django.conf.urls.static import static
urlpatterns = [
path("", views.index, name="index"),
] |
#Output : pip install --upgrade django-crispy-forms | Django Sign Up and login with confirmation Email
from django.urls import path, include
from django.conf import settings
from . import views
from django.conf.urls.static import static
urlpatterns = [
path("", views.index, name="index"),
]
#Output : pip install --upgrade django-crispy-forms
[END] |
Django Sign Up and login with confirmation Email | https://www.geeksforgeeks.org/django-sign-up-and-login-with-confirmation-email-python/ | from django.shortcuts import render, redirect
from django.contrib import messages
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import AuthenticationForm
from .forms import UserRegisterForm
from django.core.mail import send_m... |
#Output : pip install --upgrade django-crispy-forms | Django Sign Up and login with confirmation Email
from django.shortcuts import render, redirect
from django.contrib import messages
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import AuthenticationForm
from .forms import Use... |
Django Sign Up and login with confirmation Email | https://www.geeksforgeeks.org/django-sign-up-and-login-with-confirmation-email-python/ | from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class UserRegisterForm(UserCreationForm):
email = forms.EmailField()
phone_no = forms.CharField(max_length=20)
first_name = forms.CharField(max_length=20)
last_name = forms.CharF... |
#Output : pip install --upgrade django-crispy-forms | Django Sign Up and login with confirmation Email
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class UserRegisterForm(UserCreationForm):
email = forms.EmailField()
phone_no = forms.CharField(max_length=20)
first_name = forms.Cha... |
ToDo webapp using Django | https://www.geeksforgeeks.org/python-todo-webapp-using-django/ | from django.contrib import admin
from django.urls import path
from todo import views
urlpatterns = [
#####################home_page###########################################
path("", views.index, name="todo"),
####################give id no. item_id name or item_id=i.id ############
# pass item_id as ... |
#Output : django-admin startproject todo_site | ToDo webapp using Django
from django.contrib import admin
from django.urls import path
from todo import views
urlpatterns = [
#####################home_page###########################################
path("", views.index, name="todo"),
####################give id no. item_id name or item_id=i.id ##########... |
ToDo webapp using Django | https://www.geeksforgeeks.org/python-todo-webapp-using-django/ | from django.db import models
from django.utils import timezone
class Todo(models.Model):
title = models.CharField(max_length=100)
details = models.TextField()
date = models.DateTimeField(default=timezone.now)
def __str__(self):
return self.title |
#Output : django-admin startproject todo_site | ToDo webapp using Django
from django.db import models
from django.utils import timezone
class Todo(models.Model):
title = models.CharField(max_length=100)
details = models.TextField()
date = models.DateTimeField(default=timezone.now)
def __str__(self):
return self.title
#Output : django-ad... |
ToDo webapp using Django | https://www.geeksforgeeks.org/python-todo-webapp-using-django/ | from django.shortcuts import render, redirect
from django.contrib import messages
# import todo form and models
from .forms import TodoForm
from .models import Todo
###############################################
def index(request):
item_list = Todo.objects.order_by("-date")
if request.method == "POST":
... |
#Output : django-admin startproject todo_site | ToDo webapp using Django
from django.shortcuts import render, redirect
from django.contrib import messages
# import todo form and models
from .forms import TodoForm
from .models import Todo
###############################################
def index(request):
item_list = Todo.objects.order_by("-date")
if req... |
ToDo webapp using Django | https://www.geeksforgeeks.org/python-todo-webapp-using-django/ | from django import forms
from .models import Todo
class TodoForm(forms.ModelForm):
class Meta:
model = Todo
fields = "__all__" |
#Output : django-admin startproject todo_site | ToDo webapp using Django
from django import forms
from .models import Todo
class TodoForm(forms.ModelForm):
class Meta:
model = Todo
fields = "__all__"
#Output : django-admin startproject todo_site
[END] |
ToDo webapp using Django | https://www.geeksforgeeks.org/python-todo-webapp-using-django/ | <!DOCTYPE html><html lang="en" dir="ltr">??????<head>????????????????"utf-8">????????????<title>{{title}}</title>???????"viewport" content="width=device-width, initial-scale=1">????????????<l"stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">????????????<scr"https://ajax.googleapi... |
#Output : django-admin startproject todo_site | ToDo webapp using Django
<!DOCTYPE html><html lang="en" dir="ltr">??????<head>????????????????"utf-8">????????????<title>{{title}}</title>???????"viewport" content="width=device-width, initial-scale=1">????????????<l"stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">????????????<s... |
Django project to create a Comments System | https://www.geeksforgeeks.org/django-project-to-create-a-comments-system/ | class Post(models.Model):
image = models.ImageField(default="default_foo.png", upload_to="post_picture")
caption = models.TextField()
date_posted = models.DateTimeField(default=timezone.now)
author = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return f"{self.author.... |
#Output : django-admin startproject my_project | Django project to create a Comments System
class Post(models.Model):
image = models.ImageField(default="default_foo.png", upload_to="post_picture")
caption = models.TextField()
date_posted = models.DateTimeField(default=timezone.now)
author = models.ForeignKey(User, on_delete=models.CASCADE)
def __... |
Django project to create a Comments System | https://www.geeksforgeeks.org/django-project-to-create-a-comments-system/ | from django import forms
from .models import Comment
class CommentForm(forms.ModelForm):
content = forms.CharField(
label="",
widget=forms.Textarea(
attrs={
"class": "form-control",
"placeholder": "Comment here !",
"rows": 4,
... |
#Output : django-admin startproject my_project | Django project to create a Comments System
from django import forms
from .models import Comment
class CommentForm(forms.ModelForm):
content = forms.CharField(
label="",
widget=forms.Textarea(
attrs={
"class": "form-control",
"placeholder": "Comment here ... |
Django project to create a Comments System | https://www.geeksforgeeks.org/django-project-to-create-a-comments-system/ | from .forms import CommentForm
def post_detailview(request, id):
if request.method == "POST":
cf = CommentForm(request.POST or None)
if cf.is_valid():
content = request.POST.get("content")
comment = Comment.objects.create(
post=post, user=request.user, conte... |
#Output : django-admin startproject my_project | Django project to create a Comments System
from .forms import CommentForm
def post_detailview(request, id):
if request.method == "POST":
cf = CommentForm(request.POST or None)
if cf.is_valid():
content = request.POST.get("content")
comment = Comment.objects.create(
... |
Django project to create a Comments System | https://www.geeksforgeeks.org/django-project-to-create-a-comments-system/ | {% load crispy_forms_tags %}<html>????????????<head>????????????<title></title>????????????</head><"POST">????????????????????????{% csrf_token %}????????????????????????{{comme |
#Output : django-admin startproject my_project | Django project to create a Comments System
{% load crispy_forms_tags %}<html>????????????<head>????????????<title></title>????????????</head><"POST">????????????????????????{% csrf_token %}????????????????????????{{comme
#Output : django-admin startproject my_project
[END] |
Voting System Project Using Django Framework | https://www.geeksforgeeks.org/voting-system-project-using-django-framework/ | from django.db import models
# Create your models here.
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField("date published")
def __str__(self):
return self.question_text
class Choice(models.Model):
question = models.ForeignKey(Que... |
#Output : pip install pipenv | Voting System Project Using Django Framework
from django.db import models
# Create your models here.
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField("date published")
def __str__(self):
return self.question_text
class Choice(models... |
Voting System Project Using Django Framework | https://www.geeksforgeeks.org/voting-system-project-using-django-framework/ | INSTALLED_APPS = [
"polls.apps.PollsConfig",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
] |
#Output : pip install pipenv | Voting System Project Using Django Framework
INSTALLED_APPS = [
"polls.apps.PollsConfig",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]
#Output : pip install pipenv
[END] |
Voting System Project Using Django Framework | https://www.geeksforgeeks.org/voting-system-project-using-django-framework/ | from django.contrib import admin
# Register your models here.
from .models import Question, Choice
# admin.site.register(Question)
# admin.site.register(Choice)
admin.site.site_header = "Pollster Admin"
admin.site.site_title = "Pollster Admin Area"
admin.site.index_title = "Welcome to the Pollster Admin Area"
clas... |
#Output : pip install pipenv | Voting System Project Using Django Framework
from django.contrib import admin
# Register your models here.
from .models import Question, Choice
# admin.site.register(Question)
# admin.site.register(Choice)
admin.site.site_header = "Pollster Admin"
admin.site.site_title = "Pollster Admin Area"
admin.site.index_title ... |
Voting System Project Using Django Framework | https://www.geeksforgeeks.org/voting-system-project-using-django-framework/ | from django.template import loader
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from .models import Question, Choice
# Get questions and display them
def index(request):
latest_question_list = Question.objects.o... |
#Output : pip install pipenv | Voting System Project Using Django Framework
from django.template import loader
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from .models import Question, Choice
# Get questions and display them
def index(request):
... |
Voting System Project Using Django Framework | https://www.geeksforgeeks.org/voting-system-project-using-django-framework/ | from django.urls import path
from . import views
app_name = "polls"
urlpatterns = [
path("", views.index, name="index"),
path("<int:question_id>/", views.detail, name="detail"),
path("<int:question_id>/results/", views.results, name="results"),
path("<int:question_id>/vote/", views.vote, name="vote"),
... |
#Output : pip install pipenv | Voting System Project Using Django Framework
from django.urls import path
from . import views
app_name = "polls"
urlpatterns = [
path("", views.index, name="index"),
path("<int:question_id>/", views.detail, name="detail"),
path("<int:question_id>/results/", views.results, name="results"),
path("<int:qu... |
Voting System Project Using Django Framework | https://www.geeksforgeeks.org/voting-system-project-using-django-framework/ | TEMPLATES = [
{
# make changes in DIRS[].
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug"... |
#Output : pip install pipenv | Voting System Project Using Django Framework
TEMPLATES = [
{
# make changes in DIRS[].
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
... |
Voting System Project Using Django Framework | https://www.geeksforgeeks.org/voting-system-project-using-django-framework/ | {% extends 'base.html' %}{% block content %}<h1 class ="text-center mb-3">Poll Questions</h1>{% if latest_question_list %}{% for question in latest_question_list %}<div class ="card-mb-3">????????????????????"card-body">??????????????????????????"lead">{{ question.question_text }}</p>???????????????????????????"{% url ... |
#Output : pip install pipenv | Voting System Project Using Django Framework
{% extends 'base.html' %}{% block content %}<h1 class ="text-center mb-3">Poll Questions</h1>{% if latest_question_list %}{% for question in latest_question_list %}<div class ="card-mb-3">????????????????????"card-body">??????????????????????????"lead">{{ question.question_t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.