Skip to content

Instantly share code, notes, and snippets.

View njanirudh's full-sized avatar
🤖

Anirudh NJ njanirudh

🤖
View GitHub Profile
#----- XOR Patterns --------
# https://www.reddit.com/r/math/comments/bpfq1w/weird_prime_pattern/
# https://medium.com/biffures/part-2-the-beauty-of-bitwise-and-or-cdf1d8d87891
import numpy as np
import cv2 as cv2
# Width and height of the image
width = 1000
height = 1000
@njanirudh
njanirudh / image_composite.py
Last active March 20, 2019 13:36
Creates a composite image
import cv2
import glob
import os
import random
import numpy as np
def create_composite_image(_fg_image , _bg_image):
"""
Creates composite images from a given set of foreground and background images
@njanirudh
njanirudh / Creating a C++ project Zip
Last active April 11, 2018 03:23
Creating simple standalone linux C++ project
# The below command will copy all the libraries that are required by an executable
# It runs 'ldd' command on the executable name.
# Replace the <file> with your exec path and <path> with the folder where the libs should be copied.
ldd <file> | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' <path>
# The below command changes the rpath for the exectable to the required path of the copied libraries.
chrpath -r '$ORIGIN/<path>' <file>
@njanirudh
njanirudh / cpp_script
Created February 7, 2018 08:14
Directory reader in pure cpp
#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
static void list_dir(const char *path)
{
struct dirent *entry;
DIR *dir = opendir(path);
if (dir == NULL) {
return;
@njanirudh
njanirudh / OpenCV NDK
Last active August 9, 2019 09:00
Creating a template app for OpenCV NDK
##Using Android OpenCV-Java and Native C++
Create a new android Project with Include C++ Support.
Download the android sdk from http://opencv.org/releases.html.
Import OpenCV4Android as a module dependency of your app. In your Android Studio Project, select File -> New -> Import Module.. . Then in the New Module dialog, navigate to the path of OpenCV4Android Java SDK. For instance path is
<Path to Downloads>/opencv-android-sdk/sdk/java .
Go to File -> Project Structure .Select app -> dependencies . Press + and select Module Dependency. Press Ok.
Now we need to add native JNI libraries in our project. These libraries should be added in jniLibs directory. Create a new jniLibs directory in app-> src -> main.
Open the extracted OpenCV SDK directory. Switch to “opencv-android-sdk/sdk/native/libs” directory.
@njanirudh
njanirudh / AR_ToolKit_Linux
Last active January 4, 2018 09:41
Running AR-ToolKit 5 on Linux
Tested on :-
ARToolKit5-bin-5.3.2r1-Linux-x86_64
Linux 16.04
Installation Steps :-
1. Download and extract the AR-Toolkit from the Official website .(https://archive.artoolkit.org/download-artoolkit-sdk)
2. Go to <ARToolKit5 Root Directory>/bin and run ./nftSimple
3. You might get an error regarding missing 'libglut.so'
@njanirudh
njanirudh / PointsSort.txt
Created August 17, 2017 12:01
Function to sort points
//Function To sort the points
inline void sortPoints(std::vector < cv::Point > &pointList)
{
std::sort(pointList.begin(),pointList.end(),Local());
}
//Comparator funtion for sorting the points
struct Local {
bool operator () (const cv::Point & p1, const cv::Point & p2)