5. Using a Logitech C270 webcam

About Logitech C270 webcam

You can make a pretty decent stereo vision system with a Logitech C270 webcam that you can buy for around 2000 yen. This is the camera for the introduction video on the website. I tried the excellent industrial cameras of Germany IDS (Imaging Development Systems) and Germany TIS (The Imaging Source) around 2016, but it is assumed that they will be used in the SDK provided together. Using it in combination with OpenCV, OpenGL, or CUDA seemed quite difficult. I gave up on the way. Even if it says that it is UVC (USB Video Class) compatible, it may be because of Ubuntu, but there is a memory that did not work properly in my environment. So, for the time being, the Logitech C270 webcam we used was pretty good, so I keep using it. In the following, it is assumed that this camera will be used, but I think that it can be used in the same way if it is a camera of the same rank of Logitech.

Usable camera

Of course we were able to use Logitech C270.

A USB3.0-UVC camera using FCB-MA130 (manufactured by SONY) of a company called Infinitegra in Shin-Yokohama was also used.

ZED from STEREOLABS, a famous stereo vision camera, was also used. In ZED, images from two cameras, that is, stereo images, are transferred as one camera image.

IDS's cheap USB 2.0 camera, LE series UV-1551LE-C was also used.

I could use Logitech's slightly expensive C922 Pro Stream Webcam.

Distributing a program for video display of webcam images

camera.cpp Download cameras.cpp and makefile , put them in the same directory, and set it to

make one
. The camera image will be displayed in a video window.
make two
Then the images from the two cameras will be displayed in video in two windows. If two windows are overlapped, move the windows with the mouse. Both end when a key is pressed. camera.cpp is for one and cameras.cpp is for two.

Program description

camera.cpp is as follows using OpenCV library functions.

#include <opencv2/highgui/highgui.hpp>

int main(int argc, const char** argv) {
  cv::VideoCapture cap0(0);
  if (cap0.isOpened()) printf("camera successfully opened\n");
  else               { printf("cannot open camera\n"); return 1; }
  cv::namedWindow("image0", cv::WINDOW_AUTOSIZE);
  cv::Mat frame0;
  for ( ; ; ) {
    cap0 >> frame0;
    cv::imshow("image0", frame0);
    if (cv::waitKey(30) >= 0) break;
  }
  return 0;
}
waitKey (30) is a function that waits for key input for 30 ms, returns the key code if there is a key input, and returns -1 if there is no key input. I think that the other functions have some meaning. The makefile for this program is
LFLAGS = -O3 `pkg-config opencv --cflags --libs`
.SUFFIXES:
camera: camera.cpp
	g++ -o $@ camera.cpp $(LFLAGS)
one: camera
	./camera
clean:
	rm -f camera
. This program can also be used to test if OpenCV is properly installed.

Extension without permission

Also, it seems that sometimes makefile.txt is appended with the extension .txt when makingfile is downloaded. I use the download attribute of HTML5, but there seems to be a case where the extension .txt is not attached even if it is described in the same way. I tried many things to see where this difference occurred, but I didn't understand. You may want to download files without extensions that have been archived with tar, etc., but that is cumbersome, so leave it as it is. When it becomes makefile.txt, rename it to makefile.