Skip to content

Instantly share code, notes, and snippets.

View pAkalpa's full-sized avatar
🎯
Focused on FYP

Pasindu Akalpa pAkalpa

🎯
Focused on FYP
View GitHub Profile
@pAkalpa
pAkalpa / Vagrantfile
Created June 12, 2024 19:17
Sample Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
$rootScript = <<SCRIPT
cd /home/vagrant
@pAkalpa
pAkalpa / crop_img.py
Created March 21, 2023 18:08
Crop Images using Yolo Model Output
import numpy as np
import cv2
# Get bounding boxes from the model
results = model(input_img)
boxes = results[0].boxes
# Iterate over all boxes and crop image segments
cropped_images = []
for box in boxes:
@pAkalpa
pAkalpa / background_detection.py
Created March 6, 2023 09:26
This code is used to detect background less images and add white background if background is not present.
from PIL import Image
def add_white_background(image_path):
# Open the image
image = Image.open(image_path)
# Check if the image has a transparent background
if image.mode == 'RGBA':
# Add a white background
@pAkalpa
pAkalpa / Extract Content from Paper.py
Created March 5, 2023 12:51
This Code snippet help to extract features from plain color background.
import cv2 as cv
import numpy as np
# Load image
img = cv.imread('input_image_name.jpg', 0)
# Apply median filter to remove noise
img = cv.medianBlur(img, 5)
# Apply adaptive thresholding
@pAkalpa
pAkalpa / MAND_Lecture2.playground
Created February 11, 2023 11:22
MAND_Lecture2_Playground
import Foundation
class Person {
var clothes: String
var shoes: String
init(clothes: String, shoes: String) {
self.clothes = clothes
self.shoes = shoes
}
@pAkalpa
pAkalpa / #Question.md
Last active January 10, 2022 14:30
Designing and Implementing Classes - The US Postal Service

Question

@pAkalpa
pAkalpa / Led_Effects.ino
Created January 3, 2022 08:20
18 Effects Led Patterns for Led Strips. This Code is configured for 300Led's ws2812b Addressable Led Strip.
#include "FastLED.h"
#define NUM_LEDS 300 // Number of LEDs in strip
CRGB leds[NUM_LEDS];
#define PIN 5 // Arduino pin connected to the LED strip
byte selectedEffect=-1; // start with "-1" since the "loop" will right away increase it by 1
void setup()
{
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}