1. An image-based object counting method comprising: rasterizing a counting line in an image into counting line pixels; determining two points on a trajectory line included in the image as target pixels; determining, from the counting line pixels, corresponding pixels that correspond to the target pixels; determining whether the counting line intersects with the trajectory line based on the target pixels and the corresponding pixels; and determining a number of one or more trajectory lines including the trajectory line that intersect with the counting line as a number of objects that pass the counting line.