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 "jpg2rgb.py"

How to use: python jpg2rgb.py      


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):
            opimg.write(r[i,j])
            opimg.write(g[i,j])
            opimg.write(b[i,j])
    opimg.close()

    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..."
        sys.exit()
       
    op_rgb_file = args.op_rgb
    if not os.path.isdir(op_rgb_file):
        print "Invalid path\nExiting..."
        sys.exit()

    if(convert_jpg2rgb(ip_jpg_file, op_rgb_file)):
        print "Conversion Sucessful"
    else:
        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 - https://cmusatyalab.github.io/openface/
Code - https://github.com/cmusatyalab/openface
Torch - Frameworks - http://torch.ch/docs/getting-started.html#_
Training and classification - https://cmusatyalab.github.io/openface/demo-3-classifier/

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.



Computer Vision with MATLAB for Object Detection and Tracking

View this email as a web page. 
To ensure our emails reach your inbox, add the domain @em.mathworks.com to your safe sender list. Learn more.
MathWorks
Dear Pradeep Sakhamoori
MathWorks India invites you to a complimentary webinar:

Computer Vision with MATLAB for Object Detection and Tracking

8 May 2013
3:00 PM IST (India Standard Time)
Computer vision uses images and video to detect, classify, and track objects or events in order to understand a real-world scene. In this webinar, we dive deeper into the topic of object detection and tracking. Through product demonstrations, you will see how to:
  • Recognize objects using SURF features
  • Detect faces and upright people with algorithms such as Viola-Jones
  • Track single objects with the Kanade-Lucas-Tomasi (KLT) point tracking algorithm
  • Perform Kalman Filtering to predict the location of a moving object
  • Implement a motion-based multiple object tracking system
This webinar assumes some experience with MATLAB and Image Processing Toolbox. We will focus on the Computer Vision System Toolbox.
About the Presenter: Bruce Tannenbaum works on image processing and computer vision applications in technical marketing at MathWorks. Earlier in his career, he developed computer vision and wavelet-based image compression algorithms at Sarnoff Corporation (SRI). He holds an MSEE degree from University of Michigan and a BSEE degree from Penn State.
REGISTER now
Invite a Colleague

Register for this webinar.

Related Posts

Twitter Updates

Random Posts

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