How does a device (dashcam) recognize if it is connected to a computer or a power source?
The USB Battery charging specification is used by many USB devices to determine what type of port they are attached to.

The main types of ports are...

Dedicated charging port:  The charger indicates that it is a dedicated charging port by shorting the D+ and D- lines together.

Standard downstream port:  A USB port that supports up to 500mA of charging current (for a USB 2.0 port), plus USB data.  The device enumerates on the USB bus to determine how much current it can draw.  The bMaxPower field in the USB device descriptor is used to ask the host for power.

Charging downstream port:  A USB port that supports up to 1.5A charging curret, plus USB data.  The device determines that it is attached to a CDP by first toggling the D- line.  If the D+ line tracks the D- line then the device knows it is attached to some sort of charger.  Next the device does secondary detection by toggling the D+ line.  If the D- line stays low then the device knows that the lines are not shorted together so it must be attached to a charging downstream port.

http://www.usb.org/developers/docs/devclass_docs/batt_charging_1_1.zip