A method for an automatic parking system, comprising: obtaining a parking-line segmentation image through a segmentation neural network; preprocessing the parking-line segmentation image to obtain at least one parking-line skeleton image; and calculating straight-line equations and straight-line endpoints for parking lines in the parking-line segmentation image based on the at least one parking-line skeleton image, wherein the calculating straight-line equations and straight-line endpoints for parking lines in the parking-line segmentation image based on the at least one parking-line skeleton image comprises: performing, for each parking-line skeleton image, the following operations: A: dividing the parking-line skeleton image into multiple patches; B: generating multiple straight-line equations based on the multiple patches, wherein each straight-line equation is formed by fitting the pixels with first color in each patch; C: selecting an optimal straight-line equation from the multiple straight-line equations, wherein the optimal straight-line equation represents the straight line matching the largest quantity of pixels with first color in the parking-line skeleton image; D: calculating the corresponding endpoints of the optimal straight-line equation in the parking-line skeleton image; and E: deleting the pixels with first color corresponding to the optimal straight-line equation from the parking-line skeleton image; repeating steps B-E in a loop until the number of loops reaches a straight-line quantity threshold or the quantity of remaining pixels with first color in the parking-line skeleton image is less than a pixel quantity threshold. obtaining a parking-line segmentation image through a segmentation neural network; preprocessing the parking-line segmentation image to obtain at least one parking-line skeleton image; and calculating straight-line equations and straight-line endpoints for parking lines in the parking-line segmentation image based on the at least one parking-line skeleton image, wherein the calculating straight-line equations and straight-line endpoints for parking lines in the parking-line segmentation image based on the at least one parking-line skeleton image comprises: performing, for each parking-line skeleton image, the following operations: A: dividing the parking-line skeleton image into multiple patches; B: generating multiple straight-line equations based on the multiple patches, wherein each straight-line equation is formed by fitting the pixels with first color in each patch; C: selecting an optimal straight-line equation from the multiple straight-line equations, wherein the optimal straight-line equation represents the straight line matching the largest quantity of pixels with first color in the parking-line skeleton image; D: calculating the corresponding endpoints of the optimal straight-line equation in the parking-line skeleton image; and E: deleting the pixels with first color corresponding to the optimal straight-line equation from the parking-line skeleton image; A: dividing the parking-line skeleton image into multiple patches; B: generating multiple straight-line equations based on the multiple patches, wherein each straight-line equation is formed by fitting the pixels with first color in each patch; C: selecting an optimal straight-line equation from the multiple straight-line equations, wherein the optimal straight-line equation represents the straight line matching the largest quantity of pixels with first color in the parking-line skeleton image; D: calculating the corresponding endpoints of the optimal straight-line equation in the parking-line skeleton image; and E: deleting the pixels with first color corresponding to the optimal straight-line equation from the parking-line skeleton image; repeating steps B-E in a loop until the number of loops reaches a straight-line quantity threshold or the quantity of remaining pixels with first color in the parking-line skeleton image is less than a pixel quantity threshold.