Take photo in unity

Hey,
I’m trying to build a program that takes your photo and places it with a different background, like a monument or so.
So far, I was able to turn the camera on when I start the project with this code

    webcamTexture = new WebCamTexture();
	rawImage.texture = webcamTexture;
	rawImage.material.mainTexture = webcamTexture;
	webcamTexture.Play();

	Texture2D PhotoTaken = new Texture2D (webcamTexture.width, webcamTexture.height);
	PhotoTaken.SetPixels (webcamTexture.GetPixels ());
	PhotoTaken.Apply ();

However, I can’t take a screenshot or photo because it always ends up all black. I’ve tried different codes but nothing is working.
Can someone please help? Thanks

Try

RenderTexture PhotoTaken = new RenderTexture(webcamTexture.width, webcamTexture.height,0);
Graphics.Blit(webcamTexture,PhotoTaken);

After that, convert the RenderTexture to Texture2D to save it.