this may help you, which contains solvers based on QPTH and opencv

  
      github.com
  
  
    icoz69/DeepEMD/blob/master/Models/models/emd_utils.py 124
import cv2
import torch
import torch.nn.functional as F
from qpth.qp import QPFunction


def emd_inference_qpth(distance_matrix, weight1, weight2, form='QP', l2_strength=0.0001):
    """
    to use the QP solver QPTH to derive EMD (LP problem),
    one can transform the LP problem to QP,
    or omit the QP term by multiplying it with a small value,i.e. l2_strngth.
    :param distance_matrix: nbatch * element_number * element_number
    :param weight1: nbatch  * weight_number
    :param weight2: nbatch  * weight_number
    :return:
    emd distance: nbatch*1
    flow : nbatch * weight_number *weight_number

    """



  This file has been truncated. show original