2

I am planning to build a set up for experimentation in which I need to get automatic video capture.

My original plan was to use MATLAB and take pictures which could be joined together later (in order to avoid videos being too heavy during acquisition and because I don't need to have too many fps). MATLAB has the advantage that many users have done this before and there's plenty code available.

However, I have some problems with this original idea. Mainly, the computer I'll probably be using doesn't have/will crash because of MATLAB requirements. I was wondering if anything similar to that can be built in R.

I might also explore python alternatives (although I do not manage the language) because it seems that there are also alternatives there. But I prefer R because I'm used to it

1

Of R I am not aware of any packages that allow you to capture images from a camera. However in Python you have different options, furthermore, there are a lot of libraries available for Python, such as NumPy and SciPy which allow you to do statistical and matrix operations like in Matlab and R, and Python is easy to learn.

The different packages in Python to grab images from a camera:

OpenCV

With the following code you capture an image and can process it:

import numpy as np
import cv2    

# open the connection to the camera
cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()

    # process image: frame ..

Some tutorials

SimpleCV

Also makes it easy to process your images:

from SimpleCV import Camera
# Initialize the camera
cam = Camera()
# Loop to continuously get images
while True:
    # Get Image from camera
    img = cam.getImage()

PyGame

Finally PyGame also allows you to read frames from the camera:

import pygame
import pygame.camera
from pygame.locals import *

pygame.init()
pygame.camera.init()
cam = pygame.camera.Camera("/dev/video0",(640,480))
cam.start()
image = cam.get_image()
  • Thank you for such a complete answer, I guess I'd have to explore Python sooner or later and this might be the moment. I still can't believe nobody has uploaded to CRAN packages like these but that's another discussion – Matias Andina Nov 12 '15 at 22:23
0

There's a CRAN task view on Medical Imaging, and in the middle of the page is a section "General Image Processing", with short descriptions about the capabilities of various R packages.

At this time, I didn't find any mentions of "video" on the page.

Maybe the task-view page is still worth a closer look.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.