【Python OPENCV】matplotlib mouse events

【ANDROID STUDIO】 Get Location

【VUEJS】 Search highlight debounce

【Python OPENCV】 analog clock values opencv

 """

Example to show how to get the values for the hour markings to build the clock

"""


# Import required packages:

import math


radius = 300

center = (320, 320)


for x in (0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330):

    x_coordinate = center[0] + radius * math.cos(x * 3.14 / 180)

    y_coordinate = center[1] + radius * math.sin(x * 3.14 / 180)

    print("x: {} y: {}".format(round(x_coordinate), round(y_coordinate)))


print("..............")


for x in (0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330):

    x_coordinate = center[0] + (radius - 20) * math.cos(x * 3.14 / 180)

    y_coordinate = center[1] + (radius - 20) * math.sin(x * 3.14 / 180)

    print("x: {} y: {}".format(round(x_coordinate), round(y_coordinate)))

【ANDROID STUDIO】Geofence

【Python OPENCV】 Video Buffer and Threading

 import threading, time

import cv2

import queue


input_buffer = queue.Queue()


def processing():

    while True:

        print("get")

        frame=input_buffer.get()

        cv2.imshow("Video",frame)

        time.sleep(0.025)

        if cv2.waitKey(1) & 0xFF == ord('q'):

            break

    return


cap = cv2.VideoCapture('cats.mp4')

t = threading.Thread(target=processing)

t.start()


while True:

    ret, frame = cap.read()

    input_buffer.put(frame)

    time.sleep(0.025)

    print("put")

【Python OPENCV】 read ip camera or video

【ANDROID STUDIO】 Dial Phone number

【Python OPENCV】 argparse load image

 """

Example to load an image using argparse

"""

# Import the required packages

import argparse

import cv2

# We first create the ArgumentParser object# The created object 'parser' will have the necessary information

# to parse the command-line arguments into data types.

parser = argparse.ArgumentParser()

# We add 'path_image' argument using add_argument() including a help. The type of this argument is string (by default)

parser.add_argument("path_image", help="path to input image to be displayed")

# The information about program arguments is stored in 'parser'

# Then, it is used when the parser calls parse_args().

# ArgumentParser parses arguments through the parse_args() method:

args = parser.parse_args()

print(args.path_image)

# We can now load the input image from disk:

image = cv2.imread(args.path_image)

# Parse the argument and store it in a dictionary:

args = vars(parser.parse_args())

# Now, we can also load the input image from disk using args:

image2 = cv2.imread(args["path_image"])

# Show the loaded image:

cv2.imshow("loaded image", image)

cv2.imshow("loaded image2", image2)

# Wait until a key is pressed:

cv2.waitKey(0)

# Destroy all windows:

cv2.destroyAllWindows()

【ANDROID STUDIO】 blocked call list

【Python OPENCV】 drawing images

import cv2
import numpy as np
import os
if not os.path.exists('drawing_images'):
    os.makedirs('drawing_images')
    

# Create a black image
image = np.zeros((512,512,3), np.uint8)

# Can we make this in black and white?
image_bw = np.zeros((512,512), np.uint8)

cv2.imshow("Black Rectangle (Color)", image)
cv2.imshow("Black Rectangle (B&W)", image_bw)

cv2.waitKey(0)
cv2.destroyAllWindows()

cv2.imwrite('./drawing_images/black_rectangle.jpg', image)
cv2.imwrite('./drawing_images/black_rectangle_b_w.jpg', image_bw)

image = np.zeros((512,512,3), np.uint8)
cv2.line(image, (0,0), (511,511), (255,127,0), 5)
cv2.imshow("Blue Line", image)

cv2.waitKey(0)
cv2.destroyAllWindows()

cv2.imwrite('./drawing_images/blue_line.jpg', image)

# Draw a Rectangle in
image = np.zeros((512,512,3), np.uint8)

cv2.rectangle(image, (100,100), (300,250), (127,50,127), -1)
cv2.imshow("Rectangle", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

cv2.imwrite('./drawing_images/rectangle.jpg', image)

image = np.zeros((512,512,3), np.uint8)
cv2.circle(image, (350, 350), 100, (15,75,50), -1) 
cv2.imshow("Circle", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

cv2.imwrite('./drawing_images/circle.jpg', image)

image = np.zeros((512,512,3), np.uint8)

# Let's define four points
pts = np.array( [[10,50], [400,50], [90,200], [50,500]], np.int32)

# Let's now reshape our points in form  required by polylines
pts = pts.reshape((-1,1,2))

cv2.polylines(image, [pts], True, (0,0,255), 3)
cv2.imshow("Polygon", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.imwrite('./drawing_images/polygon.jpg', image)
image = np.zeros((512,512,3), np.uint8)

cv2.putText(image, 'Hello World!', (75,290), cv2.FONT_HERSHEY_COMPLEX, 2, (100,170,0), 3)
cv2.imshow("Hello World!", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

cv2.imwrite('./drawing_images/hello_world.jpg', image)

【Python OPENCV】 histograms

 import cv2

import numpy as np

# We need to import matplotlib to create our histogram plots
from matplotlib import pyplot as plt

image = cv2.imread('images/input.jpg')

histogram = cv2.calcHist([image], [0], None, [256], [0256])

# We plot a histogram, ravel() flatens our image array 
plt.hist(image.ravel(), 256, [0256]); plt.show()

# Viewing Separate Color Channels
color = ('b''g''r')

# We now separate the colors and plot each in the Histogram
for i, col in enumerate(color):
    histogram2 = cv2.calcHist([image], [i], None, [256], [0256])
    plt.plot(histogram2, color = col)
    plt.xlim([0,256])
    
plt.show()

【ANDROID STUDIO】 SoundPool

Building Bluesky: a Distributed Social Network (Real-World Engineering Challenges)

Bluesky is built by around 10 engineers, and has amassed 5 million users since publicly launching in February this year. A deep dive into no...

Contact Form

Name

Email *

Message *