| 842 | return True |
| 843 | |
| 844 | def _correct_split_info(self, head, neck, waist, foot, version=0): |
| 845 | standard_head = self.template_split_info[0] |
| 846 | standard_neck = self.template_split_info[1] |
| 847 | standard_waist = self.template_split_info[2] |
| 848 | standard_foot = self.template_split_info[3] |
| 849 | margin_head_neck = self.template_split_info[1] - self.template_split_info[0] |
| 850 | margin_neck_waist = self.template_split_info[2] - self.template_split_info[1] |
| 851 | margin_waist_foot = self.template_split_info[3] - self.template_split_info[2] |
| 852 | |
| 853 | delta = 0 |
| 854 | if not head < 0.3: |
| 855 | delta = head - standard_head |
| 856 | head = standard_head |
| 857 | |
| 858 | if version == 0: |
| 859 | if head < waist or neck < waist or waist < foot: |
| 860 | neck = max(head + margin_head_neck, neck - delta) |
| 861 | waist = max(neck + margin_neck_waist, waist - delta) |
| 862 | foot = max(waist + margin_waist_foot, foot - delta) |
| 863 | return head, neck, waist, foot |
| 864 | elif version == 1: |
| 865 | # if head < waist or neck < waist or waist < foot: |
| 866 | # if neck - delta <= head: |
| 867 | # neck = head + margin_head_neck |
| 868 | # else: |
| 869 | # neck -= delta |
| 870 | # if waist - delta <= neck: |
| 871 | # waist = neck + margin_neck_waist |
| 872 | # else: |
| 873 | # waist -= delta |
| 874 | # if foot - delta <= waist: |
| 875 | # foot = waist + margin_waist_foot |
| 876 | # else: |
| 877 | # foot -= delta |
| 878 | # return head, neck, waist, foot |
| 879 | raise ValueError('may be wrong') |
| 880 | else: |
| 881 | raise ValueError('unknown correction version:{}'.format(version)) |
| 882 | |
| 883 | if not head < neck: |
| 884 | neck = max(head + margin_head_neck, standard_neck) |
| 885 | if not neck < waist: |
| 886 | waist = max(neck + margin_neck_waist, standard_waist) |
| 887 | if not waist < foot: |
| 888 | foot = max(waist + margin_waist_foot, standard_foot) |
| 889 | return head, neck, waist, foot |
| 890 | |
| 891 | def _parse_split_info(self, correction=False): |
| 892 | print('parsing split_list_file:{}'.format(self.split_list_file)) |