I want to use Raspberry PI's system command `raspistill`to take images in a c program, the program line is: `system("raspistill -q 5 -vf -hf -o pic1.jpg -t 1 -th 0:0:0");`

However, when I run the program sometimes error occurs, 
it shows that:

> 
> mmal\_vc\_component\_enable- failed to enable component- ENOSPC
>  mmal- camera component couldn't be enabled
>  mmal- main- Failed to create camera component
>  mmal- Failed to run camera app. Please check for firmware updatesckquote
> 
> 
> 

And I have tried to add some parameters into /boot/config.txt:

> 
> gpu\_mem=128 start\_file=start\_x.elf fixup\_file=fixup\_x.dat  
> 
>  disable\_camera\_led=1 cam\_lwm=16 cam\_hwm=32 cam\_offline\_start=16
> 
> 
> 

However the error still always occurs sometimes (sometimes ok). I really want to solve this problem in order to continue my project. What should I do?
['https://Stackoverflow.com/questions/29314841', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4407689/']
In my case I ran the following on a Pi 4 model B

```
vcgencmd get_camera
supported=1 detected=1

raspistill -w 3280 -h 2464 -n -t 2000 -o test.png
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

make: *** [makefile:27: raspistill] Error 70

```

It turned out to be the camera. The standard camera works!
I use a Raspberry Pi 4 Model B and I had faced the same issue.
My solution was to **set the GPU Memory from 128 to 256** in the Raspberry Pi Configuration.