1. pygame
  2. pygame
  3. pygame
  4. Issues

Issues

Issue #76 wontfix

No module named _camera

Anonymous created an issue

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 <module> 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 ??

Comments (11)

  1. 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?

  2. 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 ?

  3. 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 ??

  4. 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 <module>

    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

  5. 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?

  6. Log in to comment