Counting cards (without outside help) is legal. But casinos obviously don’t like it, because it costs them money. And — surprise! — casinos don’t like to lose money: casinos are in the business of helping gamblers lose money. Now casinos are using computers and video cameras to automate the process of detecting card counters:
The anti-card-counter system uses cameras to watch players and keep track of the actual “count” of the cards, the same way a player would. It also measures how much each player is betting on each hand, and it syncs up the two data points to look for patterns in the action. If a player is betting big when the count is indeed favorable, and keeping his chips to himself when it’s not, he’s fingered by the computer… and, in the real world, he’d probably receive a visit from a burly dude in a bad suit, too.
The system reportedly works even if the gambler intentionally attempts to mislead it with high bets at unfavorable times.
Card counting @ Wikipedia