Can a program capture images even if it is not ran manually [closed]

asked 2017-06-20 11:10:34 -0500

Gabdev gravatar image

updated 2017-06-21 03:21:39 -0500

I have a C++ program that is launched at boot as a service. It performs image processing on the output of a USB camera thanks to OpenCV. I would like to save images corresponding to what the camera captures before the image processing. To achieve this, I'm calling imwrite() in my code. Unfortunately I only get the screenshots when the program is ran manually in the terminal: as soon as I enable it as a service running at startup, the images are not generated anymore. Do you know why that occurs and how I could get rid of this problem?

EDIT - Problem solved

That was not a matter of OpenCV at all.

Actually I was specifying a relative path to imwrite() instead of an absolute one. I guess I thought that even though my program ran as a service, the working directory would still be the one where the executable is located. Hence the solution to my problem was to specify an absolute path to imwrite().

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2017-06-21 03:35:51.070842

Comments

OS, opencv version and compiler ?

LBerger gravatar imageLBerger ( 2017-06-20 11:31:54 -0500 )edit
1

OS is Ubuntu MATE with kernel 3.10, OpenCV version is 3.1.0, compiler is CMake 3.5.

Gabdev gravatar imageGabdev ( 2017-06-20 11:41:28 -0500 )edit

I don't know linux but cmake is not a compiler

LBerger gravatar imageLBerger ( 2017-06-20 13:00:34 -0500 )edit

My bad! Compiler is gcc 5.4.0.

Gabdev gravatar imageGabdev ( 2017-06-21 02:59:00 -0500 )edit