cv2.error: ScannedMapDigitizer

696
1
04-14-2022 11:52 AM
Sergey_Grechkin
New Contributor II

I'm trying to repeat the code from  https://developers.arcgis.com/python/guide/geo-referencing-and-digitization-of-scanned-maps/

 

 

from arcgis.learn import ScannedMapDigitizer

smd = ScannedMapDigitizer(r"D:\Arcgis\TEST\RASTER", r"D:\Arcgis\TEST\RASTER\OUT")
smd.create_mask(color_list=[[115, 178, 115]], color_delta=10, kernel_size=[3, 3], kernel_type="rect", show_result=False)
smd.create_template_image([100, 100,100], 10, 4, show_result= False)
extent = {
'spatialReference': {'wkid': 4326},
'xmin': -180,
'ymin': -89,
'xmax': 180,
'ymax': 85
}

smd.set_search_region_extent(extent)
ssearch_extent = {
'spatialReference': {'wkid': 4326},
'xmin': -180,
'ymin': -89,
'xmax': 180,
'ymax': 85
}
smd.prepare_search_region(r"D:\Arcgis\cover2_admin_M1-1.0\cover2_admin_M1-1.0.shp", [255, 255, 255], search_extent, 2068, 3744, show_result=True)
smd.match_template_multiscale(0.2, 2.0, 40, show_result=False)
smd.georeference_image((150, 50), show_result=False)
smd.digitize_image(show_result=False)

 

The script throws an error

Traceback (most recent call last):
File "D:\Arcgis\SCRIPT\LEARN.py", line 4, in <module>
smd.create_mask(color_list=[[115, 178, 115]], color_delta=10, kernel_size=[3, 3], kernel_type="rect", show_result=False)
File "C:\Users\WF\AppData\Local\Programs\Python\Python39\lib\site-packages\arcgis\learn\_scannedmapdigitizer.py", line 1763, in create_mask
rgb_img = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

Tell me where I went wrong ???

0 Kudos
1 Reply
by Anonymous User
Not applicable

A little late to reply... but how are you running this code?

That error looks like it's calling OpenCV from your D drive. Do you have OpenCV installed more than once on your computer (outside of ArcPro)?

There are some notorious Python/Conda OpenCV installation and path conflict issues. Perhaps for some reason arcpy is seeing the wrong cv2.

0 Kudos