954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

python code for taking images with webcam in Linux

Hey friends lets checkout a small, simple and cute python program for taking photos with with your webcam without the help of any third party application programs.

import os
   import datetime
   import opencv.adaptors
   from opencv import highgui 
   import Image

   def get_image(camera):
       im = highgui.cvQueryFrame(camera)
        # Add the line below if you need it (Ubuntu 8.04+)
       im = opencv.cvGetMat(im)
      #convert Ipl image to PIL image
   dir(im)
   print "image taken"
       return opencv.adaptors.Ipl2PIL(im) 

   #_______________find usernae___________
   a=os.popen('whoami')
   l=a.read() 
   s=l.split('\n')
   uname=s[0]

   #______________find date n time  _________
   now = datetime.datetime.now()
   now = str(now)
  
   im=None
   camera= highgui.cvCreateCameraCapture(0)
   im = get_image(camera)
   os.chdir('/home/%s/Pictures' %(uname) )
   fname='image_'+now+'.png'
   im.save(fname, "PNG")
   ####  code ends here


for more details check crack bytezz

jintujacob
Newbie Poster
4 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Your indention is off, for other things I can not help as you do not explain your problem.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 
Your indention is off, for other things I can not help as you do not explain your problem.


I think it's just a code snippet. Gives me some ideas for retrieving movies from my camcorder though.

txwooley
Junior Poster in Training
84 posts since Apr 2009
Reputation Points: 10
Solved Threads: 7
 
I think it's just a code snippet. Gives me some ideas for retrieving movies from my camcorder though.

that' it...:cool:

jintujacob
Newbie Poster
4 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: