Python code to convert jpg to rgb format

Below utility will help convert
jpeg file to rgb file format

Any question leave a comment.

Save the code to a file ""

How to use: python      

import cv2
import os, sys
import numpy as np
import argparse

def convert_jpg2rgb(ipfile, opfile):

    # Decoding input jpeg file
    ipimg = cv2.imread(ipfile, cv2.IMREAD_COLOR)

    # Shape of input image
    w, h, d = ipimg.shape

    # Reading clip name
    s = ipfile.split('\\')
    clip_name = str(s[len(s)-1])

    s = clip_name.split('.')
    clipName = str(s[0])
    # Reading B, G, R buffers
    b, g, r = cv2.split(ipimg)

    opimg = open(opfile + '/' + str('rgb_') + str(clipName) + str('.rgb'), 'wb')

    for i in range(0, h):
        for j in range(0, w):

    return True

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('ip_jpg', help="Path to Input jpg file")
    parser.add_argument('op_rgb', help="Path to save rgb file")
    args = parser.parse_args()
    return args

if __name__ == "__main__":
    args = parse_args()

    ip_jpg_file = args.ip_jpg

    if not os.path.isfile(ip_jpg_file):
        print "jpg file Not found\nExiting..."
    op_rgb_file = args.op_rgb
    if not os.path.isdir(op_rgb_file):
        print "Invalid path\nExiting..."

    if(convert_jpg2rgb(ip_jpg_file, op_rgb_file)):
        print "Conversion Sucessful"
        print "Conversion Failed"

Face Recognition - Machine Learning - Deep Neural Networks

Face Recognition is very hard problem to solve using traditional CV techniques considering hard real world scenarios lighting, camera angle etc

Far better accuracy can be achieved in Face Recognition using Deep Neural Networks called Openface an opensource free software from Carnegie Mellon university

I have been working on this for couple of months now and very impressed with the outcome

To Try it out -

Follow these steps

Introduction -
Code -
Torch - Frameworks -
Training and classification -

System requirements

Linux 12+
Python 2.7+ with additional dlib, sckit packages
CudNN drivers - If using nvidia GPU

Any questions with setup or how to ..
please leave a comment will help you.

Related Posts

Twitter Updates

Random Posts

share this post
Bookmark and Share
| More
Share/Save/Bookmark Share