Face Feature(s) Detection with OpenCV

import cv2


face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
eye_cascade = cv2.CascadeClassifier("haarcascade_eye.xml")
smile_cascade = cv2.CascadeClassifier("haarcascade_smile.xml")


cap = cv2.VideoCapture(0)

while True:
    ret, img = cap.read()
    gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, 1.3, 5)
    for (x, y, w, h) in faces:
        cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
        roi_gray = gray[y:y+h, x:x+w]
        roi_color = img[y:y+h, x:x+w]

        smile = smile_cascade.detectMultiScale(
            roi_gray,
            scaleFactor=1.6,
            minNeighbors=35,
            minSize=(25, 25),
            flags=cv2.CASCADE_SCALE_IMAGE
        )

        for (x, y, w, h) in smile:
            print("Smile Detected")
            cv2.rectangle(roi_color, (x, y), (x + w, y + h), (255, 255, 0), 2)

        eyes = eye_cascade.detectMultiScale(roi_gray)
        for (ex, ey, ew, eh) in eyes:
            cv2.rectangle(roi_color, (ex, ey), (ex + ew, ey + eh), (0, 255, 0), 2)

    cv2.imshow('img', img)
    k = cv2.waitKey(30) & 0xff
    if k == 27:
        break

cap.release()
cv2.destroyAllWindows()

^ The above script detects facial features such as face,eyes and smile.There are tons of pre-trained haarcascades available for OpenCV that you can use to detect objects such as Moving cars, traffic signs etc.

 

drawaframe – A simple way to generate decorative frames for CLI applications

I wrote a small python module to help create decorative intro’s for CLI application.It’s also my first PyPi module 😀

Example

from drawaframe import Draw


Draw.draw_char("*", 20)

Draw.ndraw(14, 6, "", "|")

Draw.draw_char("*", 20)
/usr/bin/python3.6 /home/z/PycharmProjects/draw/playground.py
********************
|                   |
|                   |
|                   | 
|                   |
|                   |
|                   |
********************

Process finished with exit code 0


you can install drawaframe by running pip install command:

sudo -H pip install drawaframe

GitHub

PyPi

Whirlpool hashing with OpenSSL in C++

#include <iostream>
#include <cstring>
#include <openssl/whrlpool.h>

using namespace std;

int main(int argc, char** argv) {

 cout << "you have entered:" << argv[1] << endl;

 char hash = argv[1][0];

 unsigned char digest[WHIRLPOOL_DIGEST_LENGTH];
 char tohash[] = {hash};

 WHIRLPOOL((unsigned char*)&tohash,strlen(tohash),(unsigned char*)&digest);

 char mdString[300];

 for(int i = 0; i < 64; i++)
 sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]);

 printf("whirlpool digest: %s\n", mdString);

 return 0;
}
[email protected]:~/CLionProjects/playground$ g++ main.cpp -o whash -lcrypto
[email protected]:~/CLionProjects/playground$ ./whash "Hello World"
you have entered:Hello World
whirlpool digest: c0cb42019e235d0c82318d44aab396357457c1d4aaa8b2721d39893b78b80b7db2e2ef6cf1f3d3fdc7f4ffd471f8d46c8a057b68188796b6f4d1574be7af8df0

Yahoo! cricket (proxy) API /w Django + RESTful Framework.

UPDATE 30-1-2018: Function updated to work on new Yahoo! Cricket API.

 

import requests
import json


def yahoo_cric_api(match_id):
    url = "https://cricket.yahoo.net/sifeeds/cricket/live/json/{}.json".format(match_id)
    response = requests.request("GET", url)
    json_data = json.loads(response.text)
    return json_data

 

A small django app mirror for yahoo! cricket API.It just calls Yahoo! cricket api when a request is made and return’s json response.

 

UPDATE:

Live:

https://x.extrapi.top/cric/MATCH_ID/

 

BookMyShow bot [+ With Notifications!]

 


Output (example):

Asian GPR Multiplex: Kukatpally
Asian M Cube Mall: Attapur
Asian Radhika Multiplex: ECIL
Cineplanet Multiplex: Kompally
Manju Cinema: Kalasiguda
Select Talkies: Bolaram
Sree Rama Theatre: Bahadurpura
___________________________
Total 7 theaters found as of 2018-01-04 19:37:08.518491.
___________________________

Integrate Lychee with Google Analytics

Lychee is a cool-looking open source album script.the best reason to choose lychee is that 1.it does not compress the images(unlike imgur!). 2.can display technical information such as EXIF data. You can find more information about lychee in their website.

lychee.electerious.com




Now, i will show you how to integrate Google Analytics(GA) with your lychee. I assume you have already added your website to google analytics. If not

1.add your domain to google analytics

2.in the root Doc F, open index.html

Put the GA code in between <head> </head> tags as shown above.

 


3.in root Doc F, open view.php

Put the GA code in-between <head> and </head>

 


It might take up to 1 hour for GA to integrate with your website and start showing stats.