Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named _camera #76

Closed
illume opened this Issue Aug 24, 2011 · 9 comments

Comments

Projects
None yet
1 participant
@illume
Copy link
Member

illume commented Aug 24, 2011

Originally reported by: Anonymous


Hi,
When ever a call to the pygame.camera.init() module is made, it raises this error message : (this is under windows 7)

""
Traceback (most recent call last):
File "C:....py", line 1, in
pygame.camera.init()
File "C:\Python27\lib\site-packages\pygame\camera.py", line 42, in init
import _camera
ImportError: No module named _camera
""

Has any solution been found for this problem ??


@illume

This comment has been minimized.

Copy link
Member Author

illume commented Aug 24, 2011

Original comment by cgohlke (Bitbucket: cgohlke, GitHub: cgohlke):


Not all pygame binary distributions include the _camera.pyd extension.

Try pygame-1.9.2pre.win32-py2.7.exe from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

@illume

This comment has been minimized.

Copy link
Member Author

illume commented Aug 25, 2011

Original comment by Anonymous:


Thank you, the above problem is solved.
I had an other problem i.e. with respect to the capturing of a image from a webcam and saving it.
I wrote a small code to do this, but on executing the program i am just getting a black(blank) image of size(640,480).

"import pygame

from pygame import camera

pygame.init()

pygame.camera.init()

window = pygame.display.set_mode((640,480),0)

cam = pygame.camera.Camera(0)

cam.start()

image = cam.get_image()

pygame.image.save(window,'abc.jpg')

cam.stop()"

It also opens the pygame window but that is also blank, and it goes to the NOT RESPONDING state in a seconds time.
Any solutions you could suggest me regarding the above?

@illume

This comment has been minimized.

Copy link
Member Author

illume commented Aug 25, 2011

Original comment by Anonymous:


I don't understand what that means: "Changed component from nothing to camera."
Do you mean the packages imported.
I also tried

"

import pygame

import pygame.camera

from pygame.locals import *

"

it still does not work ? Any suggestions ?

@illume

This comment has been minimized.

Copy link
Member Author

illume commented Aug 26, 2011

Original comment by René Dudfield (Bitbucket: illume, GitHub: illume):


Hi,

it looks like the camera package is not working on your system. The package is not complete, so it does not work on all platforms yet. Which OS are you on?

@illume

This comment has been minimized.

Copy link
Member Author

illume commented Aug 26, 2011

Original comment by Anonymous:


Oh ok now i get it ..
I am using Windows 7.

I just got it to work .. Here's a simple code :

"""

import pygame

import pygame.camera

from pygame.locals import *

import time

pygame.init()

pygame.camera.init()

size = (640,480)

d = pygame.display.set_mode(size,0)

s = pygame.surface.Surface(size,0,d)

cam = pygame.camera.Camera(0,size)

cam.start()

s = cam.get_image(s)

p=("outimage.jpg")

pygame.image.save(s,p)

"""

This opens the pygame window which still is "NOT RESPONDING" but the image is stored in the memory ... Hope this helps someone else trying out pygame.

Now i was trying to change the frame rate, exposure time, etc . . Is it possible to control those by the pygame package ?? Any suggestion ??

@illume

This comment has been minimized.

Copy link
Member Author

illume commented Aug 26, 2011

Original comment by René Dudfield (Bitbucket: illume, GitHub: illume):


Hi,

you'll need to have an event loop in there. Otherwise the window can not process events.

See the examples for how it is done.

cheers,

@illume

This comment has been minimized.

Copy link
Member Author

illume commented Aug 27, 2011

Original comment by Anonymous:


Hi,

I had a look at the events loop but it is not very clear why that is required(is it just used to stop the camera on a certain event) ? could you kindly give me a small explanation. could i not directly use the self.cam.stop() command without the event check??

what does it mean "if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE)"
does that mean i have to press the down arrow key and then press escape ?? how do i enable the QUIT part ?

I had an other problem with the query_image, once i put the command in then i get an error as :

""

Traceback (most recent call last):

File "C:/.... .py", line 49, in

if self.cam.query_image():

AttributeError: Camera instance has no attribute 'query_image'

"""

I looked at the pygame files and it has no query_image instance, but all the sources say there is a query_image instance. Am i making a mistake or Is there any alternate i could use??
I have to try the query_image instance as the material says "if you don't want to tie the framerate to the camera, you can check if the camera has an image ready." This would help in the setting of the frame rate to a certain value such that a image is present before the next image is captured. Am i understanding that right ?

Is there any way to control the exposure rate as well ?

What do you suggest ?

Cheers

@illume

This comment has been minimized.

Copy link
Member Author

illume commented Feb 12, 2012

Original comment by Anonymous:


I am having the same problem as the original poster stated: "ImportError: No module names _Camera".

I am running a program which works on Ubuntu 10.04 with Python 2.6.5 and PyGame 1.9.1

It does not work on Windows XP SP3 with ActiveState Python 3.1.3.5 and PyGame 1.9.1
It does not work on Windows XP SP3 with Python 2.7 and PyGame 1.9.2a0

In each case it does this:

>>> ================================ RESTART ================================
>>> import pygame.camera
>>> pygame.camera.init()

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    pygame.camera.init()
  File "C:\Python27\lib\site-packages\pygame\camera.py", line 42, in init
    import _camera
ImportError: No module named _camera
>>> 

(Strangely, the library file camera.py looks the same on both the working Ubuntu machine and the non-working XP machine in that it says "import _camera" on line 42 of both.)

Any ideas?

@illume

This comment has been minimized.

Copy link
Member Author

illume commented Jul 7, 2012

Original comment by René Dudfield (Bitbucket: illume, GitHub: illume):


The camera module will need to be re-factored to be fixed. Closing this bug.

@illume illume added major bug labels Mar 26, 2017

@illume illume closed this Mar 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.