Any way to get V4L2 Webcam to work with VideoTexture under Linux?

Hi so as I described in the title. Is it possible? I’ve tried many scripts and .blend files posted here but the texture was only gray and the webcam won’t turn on. I’m doing this on Ubuntu 11.04 - 32bit, Asus Eee 900A with V4L2 compatible webcam

I don’t have Linux running on my PC, so I cant test it. But you can try use the Python OpenCV library to grab the video. I don’t know if it works with Blender 2.57, about it using the parts from the PIL library which is not working with Python 3.x.

 
import opencv
#this is important for capturing/displaying images
from opencv import highgui 
 
camera = highgui.cvCreateCameraCapture(0)
def get_image():
    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
    return opencv.adaptors.Ipl2PIL(im) 

i’ve tried this in blender 2.49a and 2.57 and it cant import opencv module…

OpenCV is no Blender library. You must download it http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.2/.
Also the code above is only for the video grabbing you must connect the outputimage to the video texture modul to render the imgae on a plane.

start up a terminal and run this before you start blender (in same terminal)

export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so

greetings,
moerdn

hi. i’ve to modify the command to this to get it working

LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so blender

and i’m using this script in blender 2.49a


import VideoTexture  
  
contr = GameLogic.getCurrentController()  
obj = contr.owner  
  
if not hasattr(GameLogic, 'video'):  
    matID = VideoTexture.materialID(obj, 'MAReflection')  
    GameLogic.video = VideoTexture.Texture(obj, matID)  
    movie = '/dev/video0'  
    GameLogic.video.source = VideoTexture.VideoFFmpeg(movie)  
    GameLogic.video.source.scale = True  
if hasattr(GameLogic, 'video'):  
  GameLogic.video.refresh(True)

it finaly turn my webcam on (the light that indicate its state, so the webcam is now working), but it also freeze the blender and nothing show on the texture. i’m not able to turn of the webcam. so i have to reboot…

Do you use Ubuntu 11.04 32bit or 64bit?

Edit:
Forget it, I saw in the first post you use 32bit.