The first error on F#

Copy the first demo program from Expert F# to VS2008. There has a compiler error with split function when I compiler the program. I found a solution from internet likes below:

Code
Listing 2-1. Analyzing a String for Duplicate Words
#light
/// Analyze a string for duplicate words
let wordCount text =
    
let words = String.split [' '] text
    
let wordSet = Set.of_list words
    
let nWords = words.Length
    
let nDups = words.Length - wordSet.Count
    (nWords,nDups)
let showWordCount text =
    
let nWords,nDups = wordCount text
    printfn 
"--> %d words in the text" nWords
    printfn 
"--> %d duplicate words" nDups

开始错误:error FS0039: The value, constructor, 
namespace or type 'split' is not defined. A construct with this name was found in FSharp.PowerPack.dll, which contains some modules and types that were implicitly referenced in some previous versions of F#. You may need to add an explicit reference to this DLL in order to compile this code.
解决:在代码前面添加 
#@"FSharp.PowerPack";;(不过这只在F# Interactive (Console)下管用)。在.net里在工程文件的引用里添加FSharp.PowerPack.dll
-----创建一个工程项目的时候,带了一个引用文件夹,这里面可以添加你项目要用的库------
右键单击“References”选择“Add References”,进去后选择“.NET”下的“FSharp.PowerPack”,然后确定就OK了。

Thanks the guy shared this on his blog.

Another way to run the demo program is on command line.
1. Open a command line window
2. Go to the FSharp installed path
3. Type the fsi.exe (it is the F# interactive environment)
4. Type #help;; command, it will show the help of F# interactive environment.
5. Copy the demo program and paste it to command line window, notice: should type the ;; at the end.
If you press the enter key, you will get a compiler error about the split function. Now, we know the DLL file missed. We can use the
#r "FSharp.PowerPack.dll";;
command to  set reference dll file.
6. Paste the program again, then you will get the
val wordCount : string -> int * int
val showWordCount : string -> unit
If you get the message, it means your first F# program works well now.

详细解释一下这段代码,每一句都要进行注解:tgt = f'/kaggle/working/{dataset}-{scene}' # Generate a simple reconstruction with SIFT (https://en.wikipedia.org/wiki/Scale-invariant_feature_transform). if not os.path.isdir(tgt): os.makedirs(f'{tgt}/bundle') os.system(f'cp -r {src}/images {tgt}/images') database_path = f'{tgt}/database.db' sift_opt = pycolmap.SiftExtractionOptions() sift_opt.max_image_size = 1500 # Extract features at low resolution could significantly reduce the overall accuracy sift_opt.max_num_features = 8192 # Generally more features is better, even if behond a certain number it doesn't help incresing accuracy sift_opt.upright = True # rotation invariance device = 'cpu' t = time() pycolmap.extract_features(database_path, f'{tgt}/images', sift_options=sift_opt, verbose=True) print(len(os.listdir(f'{tgt}/images'))) print('TIMINGS --- Feature extraction', time() - t) t = time() matching_opt = pycolmap.SiftMatchingOptions() matching_opt.max_ratio = 0.85 # Ratio threshold significantly influence the performance of the feature extraction method. It varies depending on the local feature but also on the image type # matching_opt.max_distance = 0.7 matching_opt.cross_check = True matching_opt.max_error = 1.0 # The ransac error threshold could help to exclude less accurate tie points pycolmap.match_exhaustive(database_path, sift_options=matching_opt, device=device, verbose=True) print('TIMINGS --- Feature matching', time() - t) t = time() mapper_options = pycolmap.IncrementalMapperOptions() mapper_options.extract_colors = False mapper_options.min_model_size = 3 # Sometimes you want to impose the first image pair for initialize the incremental reconstruction mapper_options.init_image_id1 = -1 mapper_options.init_image_id2 = -1 # Choose which interior will be refined during BA mapper_options.ba_refine_focal_length = True mapper_options.ba_refine_principal_point = True mapper_options.ba_refine_extra_params = True maps = pycolmap.incremental_mapping(database_path=database_path, image_path=f'{tgt}/images', output_path=f'{tgt}/bundle', options=mapper_options) print('TIMINGS --- Mapping', time() - t)
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值