I would call the first a cap and the second a hat - prob'ly has something to do with the presence or absence of a brim

I suspect trying to work out what is a hat and what a cap would only result in a lot of idiolectal differences. Is it a baseball cap or a baseball hat?