as I understand your question, you are mainly trying to detect the edges of the card? Or are you trying to separate the card completely (i.e. cut out) from the image?
Your use of gamma is simply changing apparent contrast of the entire image after you convert it to gray. OpenCV has a lot of edge and object detection routines of its own, as I am assuming you are trying to do pre-processing to help?
A CONCEPTS (Not Code) ANSWER:
SEPARATE CHANNELS
Let me point you in a different direction. If the input images are always color, consider using only one of the three RGB color channels. Here's an example:
RED CHANNEL:

GREEN CHANNEL:

BLUE CHANNEL:

Notice how much more contrast the blue channel has relative to the red channel. Depending on the image contents, you will typically find that one channel has better separation for the desired object.
If you look at the histogram:

You can see that the blue channel has the greatest distance between the peaks on the right (the desired object) and the left peak (bright spot on the table). But the red channel has everything bunched up in the middle.
As an idea, you could use peak detection/peak location/distance between peaks to programmatically determine relative contrasts in each color channel.
You can also determine which color channel has its peak the farthest from the same peak in another channel, and then SUBTRACT or use DIFFERENCE or DIVIDE the two channels (example of this in "channel math" below).
The Table Cloth
Now with the table cloth, it has a very high contrast pattern on it — white(gray) that is lighter than the ID card and green that is darker than the card. The card is mostly in between.
Using a curves tool from an image editor to provide a graphical example, you can see that clamping the lower AND upper levels to black, you can isolate the mid-ranged card.
But again, notice the histogram:

While nearly everything is clumped in the midrange values, the RED channel does have a small peak near black. Using this as a guide, we turn off the green and blue channels, and then CLAMP values below and values above the range of the card's value.
CURVES TOOL:

And then the resultant red channel only - note this is inverted to make the resulting contrast more clear:

SUMMARY
So the jist of these isolation concepts is to
- Examine each color channel to determine which one has best contrast. This will be looking for a peak that is most different from the other channels AND/OR looking for peaks in a channel with the widest "valley" between them.
- Clamp low and high values to isolate the desired object. This will use the peaks found in A, with a threshold, to determine the points to clamp and ramp into the desired image.
The problem with just using a general "gamma" adjustment is that you're going to be dragging the entire image around to change apparent contrast, when what you are really trying to do is eliminate (clamp) portions of the image that are not relevant.
While I realize this isn't exactly what you were asking, I hope it was useful nevertheless. Also, I'd suggest checking out more of the detection functions in OpenCV if you aren't already.
BONUS: FUN WITH CHANNEL MATH
This may or may not have utility for you, but multiplying, dividing, subtracting, difference, exclusion between color channels can sometimes help get rid of unwanted background objects. Take the table cloth and the pattern.
Lets MULTIPLY the GREEN and BLUE channels and get THIS:

Now lets DIVIDE by the RED channel

Now adjust the GAMMA of the RED channel to eliminate the tablecloth pattern (Gamma Adjusted to 1.57):

With this resultant image:

Which of course can have further contrast enhancement now that the tablecloth pattern is gone.