Getting error while getting object of interest

Hi
I am trying to execute a piece of code using Hog() to find the car from the given picture. I am facing an error when I execute the following code.

test_img = mpimg.imread('./test_images/test4.jpg')
ystart = 400
ystop = 660
scale = 1.5
colorspace = 'YUV'
orient = 11
pix_per_cell = 16
cell_per_block = 2
hog_channel = 'ALL'

rectangles = find_cars(test_img, ystart, ystop, scale, colorspace, hog_channel, svc, None, orient, pix_per_cell,cell_per_block, None, None)

The error which I am facing is given below.
ValueError: Expected 2D array, got 1D array instead:
array=[0.12365632 0.10520883 0.13647298 … 0.00876717 0.00176261 0.00102563].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

Hi,
That is not a question that would probably fall under the scope of ‘Jupyter’. Look at it this way, if you were running this outside of a Jupyter notebook in your computational environment, you’d probably get the same issue, right? So it isn’t in the scope of this forum.

Looks more like you’d want to ask wherever users discuss things or file issues from where you are sourcing your implementation of Histogram of Oriented Gradients function hang out. You don’t even reference that so I cannot provide specifics. OpenCV or scikit-image or something else? Or if you got this particular code from some source, ask there? If you go there, you may also want to provide more specifics than you did here. Unless this is such a common issue, the limited part of the error message you provide doesn’t help much. For example, it gives two suggestions you should try but from what you provided, it cannot be determined where to apply that.

It looks like from here that someone had a similar issue last year and some of the people trying to address it had a similar issue with the lack of information being provided by that user. Plus you’ll see that Jupyter wasn’t tagged as a keyword for that post, reinforcing what I said earlier about it being outside the scope of this forum.

2 Likes