Meanwhile (since QGIS 3.16 with the new overlay_crosses function) you can use QGIS expressions to automatically calculate what you want. The expression to use on the lines layer and referring to the polygon layer (replace polygon with the name of your polygon layer) looks like this - see below for an explanation. You can use this expression with field calculator. If you create a virtual field, the value will update automatically if you change the geometries of the lines or polygons or add new features - quite handy! You might also use the expression for visual purposes only when pasting it as a label (as done in the screenshot below).
array_length (
array_remove_all(
array_foreach (
overlay_crosses(
'polygon',
$geometry
),
if (
length (
intersection(
$geometry ,
@element
)
)<5,
0,
1
)
),
0
)
)
Screenshot: the line is labeled with the expression from above. As you see, some intersections are not counted (red circles) because the line is too short (<5). As well, if a line intersects more than once the same polygon (red arrows), it is counted just once:

overlay_crosses('polygon', $geometry) gets all the geometries from the layer polygon - thus applied on the line-layer, you access all the polygons, collected in an array.
array_foreach (): for each element of the array (=for each polygon), perform an operation.
The operation to perform: A) intersect the current feature (line) with each element from the array (in the array_foreach clause, refer to it with @element); B) get the length of this intersecting line with length (); C) inside an if()-clause: if this length is smaller than 5 (or every value you define here on line 15), return 0, otherwise 1.
From the resulting array, remove all 0 values with array_remove_all( ), that means: all lines that are shorter than 5. For each polygon your line crosses for 5 or more meters, you get a value of 1 in the array - thus if the line crosses 3 polygons for more than 5 meters and 2 polygons for just 1 or 2 meters, the result will be: [1,1,1].
Return the number of remaining elements in the array with array_length (). In the example from step 4, the result would be: 3.