Edward Lance Lorilla |
- 【VISUAL VB NET】ProgressBar Marque
- 【GAMEMAKER】Random Level Generator
- 【PYTHON OPENCV】blobFromImage and imagesFromBlob
【VISUAL VB NET】ProgressBar Marque Posted: 27 Apr 2021 09:38 AM PDT Imports System Imports System.Collections.GenericImports System.ComponentModelImports System.DataImports System.DrawingImports System.LinqImports System.TextImports System.Threading.TasksImports System.Windows.Forms' make sure that using System.Diagnostics; is included Imports System.Diagnostics' make sure that using System.Security.Principal; is included Imports System.Security.Principal Public Class Form1 Public Sub New() MyBase.New() InitializeComponent() End Sub Private StartPos As Integer = 0 Private TextToShow As String = "Catch me if you can :)" Private Position As Integer = 20 Private Sub timer1_Tick(sender As Object, e As EventArgs) Handles timer1.Tick Me.Refresh() Dim gra As Graphics = Me.CreateGraphics() gra.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality gra.DrawString(TextToShow, New Font("Arial", Position), New SolidBrush(Color.Black), StartPos, 35) StartPos += 10 If StartPos >= Me.Width Then StartPos = TextToShow.Length * Position * -1 End If End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End SubEnd Class |
【GAMEMAKER】Random Level Generator Posted: 27 Apr 2021 09:30 AM PDT Information about object: obj_player Sprite: spr_idle_down Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask: No Physics Object Create Event: execute code: Step Event: execute code: execute code: execute code: |
【PYTHON OPENCV】blobFromImage and imagesFromBlob Posted: 27 Apr 2021 09:22 AM PDT """ Understanding cv2.dnn.blobFromImage() and also cv2.dnn.imagesFromBlob() in OpenCV """ # Import required packages:import cv2import numpy as npfrom matplotlib import pyplot as plt def show_img_with_matplotlib(color_img, title, pos): """Shows an image using matplotlib capabilities""" img_RGB = color_img[:, :, ::-1] ax = plt.subplot(1, 4, pos) plt.imshow(img_RGB) plt.title(title) plt.axis('off') def get_image_from_blob(blob_img, scalefactor, dim, mean, swap_rb, mean_added): """Returns image from blob assuming that the blob is from only one image""" images_from_blob = cv2.dnn.imagesFromBlob(blob_img) image_from_blob = np.reshape(images_from_blob[0], dim) / scalefactor image_from_blob_mean = np.uint8(image_from_blob) image_from_blob = image_from_blob_mean + np.uint8(mean) if mean_added is True: if swap_rb: image_from_blob = image_from_blob[:, :, ::-1] return image_from_blob else: if swap_rb: image_from_blob_mean = image_from_blob_mean[:, :, ::-1] return image_from_blob_mean # Load image:image = cv2.imread("face_test.png") # Call cv2.dnn.blobFromImage():blob_image = cv2.dnn.blobFromImage(image, 1.0, (300, 300), [104., 117., 123.], False, False) # The shape of the blob_image will be (1, 3, 300, 300):print(blob_image.shape) # Get different images from the blob:img_from_blob = get_image_from_blob(blob_image, 1.0, (300, 300, 3), [104., 117., 123.], False, True)img_from_blob_swap = get_image_from_blob(blob_image, 1.0, (300, 300, 3), [104., 117., 123.], True, True)img_from_blob_mean = get_image_from_blob(blob_image, 1.0, (300, 300, 3), [104., 117., 123.], False, False)img_from_blob_mean_swap = get_image_from_blob(blob_image, 1.0, (300, 300, 3), [104., 117., 123.], True, False) # Create the dimensions of the figure and set title:fig = plt.figure(figsize=(16, 4))plt.suptitle("cv2.dnn.blobFromImage() visualization", fontsize=14, fontweight='bold')fig.patch.set_facecolor('silver') # Show the created images:show_img_with_matplotlib(img_from_blob, "img from blob " + str(img_from_blob.shape), 1)show_img_with_matplotlib(img_from_blob_swap, "img from blob swap " + str(img_from_blob.shape), 2)show_img_with_matplotlib(img_from_blob_mean, "img from blob mean " + str(img_from_blob.shape), 3)show_img_with_matplotlib(img_from_blob_mean_swap, "img from blob mean swap " + str(img_from_blob.shape), 4) # Show the Figure:plt.show() |
You are subscribed to email updates from Edward Lance Lorilla. To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google, 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
No comments:
Post a Comment