A drug delivery device comprising: a housing: a cylindrical member configured to be rotatably supported inside the housing, wherein the outer surface of the cylindrical member is provided with a track comprising a sequence of encoded images, wherein the encoded images each encode a discrete rotational position of the cylindrical member and wherein each encoded image comprises an identical predetermined geometric feature (404,502, 508); a sensor directed at the track of the cylindrical member and configured to capture an image; and a processor configured to: receive image data from the sensor; implement a geometric feature detection algorithm; detect the predetermined geometric feature (404, 502, 508) of the image; detect encoded information at a location in the received image data that is in a predefined position relative to the geometric feature (404, 502, 508), wherein the predefined position relative to the geometric feature is defined by a pixel map (400,402, 500,600) comprising an arrangement of data bits, each of which is comprised of a plurality of pixels, and wherein each pixel is assigned to a particular data bit dependant on its relative position to the geometric feature (404, 502, 508); and compare the received image data to the pixel map (400, 402, 500, 600) to identify the encoded image. a cylindrical member configured to be rotatably supported inside the housing, wherein the outer surface of the cylindrical member is provided with a track comprising a sequence of encoded images, wherein the encoded images each encode a discrete rotational position of the cylindrical member and wherein each encoded image comprises an identical predetermined geometric feature (404,502, 508); a sensor directed at the track of the cylindrical member and configured to capture an image; and a processor configured to: receive image data from the sensor; implement a geometric feature detection algorithm; detect the predetermined geometric feature (404, 502, 508) of the image; detect encoded information at a location in the received image data that is in a predefined position relative to the geometric feature (404, 502, 508), wherein the predefined position relative to the geometric feature is defined by a pixel map (400,402, 500,600) comprising an arrangement of data bits, each of which is comprised of a plurality of pixels, and wherein each pixel is assigned to a particular data bit dependant on its relative position to the geometric feature (404, 502, 508); and compare the received image data to the pixel map (400, 402, 500, 600) to identify the encoded image. receive image data from the sensor; implement a geometric feature detection algorithm; detect the predetermined geometric feature (404, 502, 508) of the image; detect encoded information at a location in the received image data that is in a predefined position relative to the geometric feature (404, 502, 508), wherein the predefined position relative to the geometric feature is defined by a pixel map (400,402, 500,600) comprising an arrangement of data bits, each of which is comprised of a plurality of pixels, and wherein each pixel is assigned to a particular data bit dependant on its relative position to the geometric feature (404, 502, 508); and compare the received image data to the pixel map (400, 402, 500, 600) to identify the encoded image.