MinerU icon indicating copy to clipboard operation
MinerU copied to clipboard

公式检测与保存

Open Jamly7 opened this issue 1 year ago • 1 comments

目前我已经通过修改代码,能将所有的公式保存成图片了(与image和table一样),但对应的md文件中的公式没有像图片和表格一样有图片链接,我应该如何修改代码完成这个功能、

Jamly7 avatar Jul 26 '24 09:07 Jamly7

@Jamly7
After saving the path of equation screenshot, you should modify functions called pipe_mk_markdown and pipe_mk_uni_format in magic_pdf/pipe/XXPipe.py

drunkpig avatar Jul 27 '24 06:07 drunkpig

目前我已经通过修改代码,能将所有的公式保存成图片了(与image和table一样),但对应的md文件中的公式没有像图片和表格一样有图片链接,我应该如何修改代码完成这个功能、

请问如何将公式保存为图片

moro0v0 avatar Mar 08 '25 03:03 moro0v0

@Jamly7 After saving the path of equation screenshot, you should modify functions called pipe_mk_markdown and pipe_mk_uni_format in magic_pdf/pipe/XXPipe.py

我在cut_image.py里面也增加了def ocr_cut_image_and_table(spans, page, page_id, pdf_bytes_md5, imageWriter): def return_path(type): return join_path(pdf_bytes_md5, type)

for span in spans:
    span_type = span['type']
    if span_type == ContentType.Image:
        if not check_img_bbox(span['bbox']) or not imageWriter:
            continue
        span['image_path'] = cut_image(span['bbox'], page_id, page, return_path=return_path('images'),
                                       imageWriter=imageWriter)
    elif span_type == ContentType.Table:
        if not check_img_bbox(span['bbox']) or not imageWriter:
            continue
        span['image_path'] = cut_image(span['bbox'], page_id, page, return_path=return_path('tables'),
                                       imageWriter=imageWriter)

增加提取公式保存为图片ru

    elif span_type == ContentType.InterlineEquation:
        if not check_img_bbox(span['bbox']) or not imageWriter:
            continue
        span['image_path'] = cut_image(span['bbox'], page_id, page, return_path=return_path('interline_equation'),
                                       imageWriter=imageWriter)
return spans

保存行间公式的代码,我为什么没有在magic_pdf目录下找到pipe文件?我是否还需要修改其他内容?

moro0v0 avatar Mar 08 '25 07:03 moro0v0