Example #1
0
def material_shape_search(request, template="material_shape_search.html", extra_context=None):

    filters = dict(MaterialShape.DEFAULT_FILTERS)

    if "contrast" in request.REQUEST and request.REQUEST["contrast"]:
        low, high = request.REQUEST["contrast"].split("-")
        if float(low) > 0:
            filters["bsdf_wd__contrast__gte"] = low
        if float(high) < 1:
            filters["bsdf_wd__contrast__lte"] = high

    if "doi" in request.REQUEST and request.REQUEST["doi"]:
        low, high = request.REQUEST["doi"].split("-")
        if int(low) > 0:
            filters["bsdf_wd__doi__gte"] = low
        if int(high) < 15:
            filters["bsdf_wd__doi__lte"] = high

    for key in ["substance", "name", "photo__scene_category"]:
        id = request.REQUEST.get(key, 0)
        if id and int(id) > 0:
            filters[key + "_id"] = id

    for key, attr in [("planar", "planar"), ("whitebalanced", "photo__whitebalanced")]:
        val = request.REQUEST.get(key)
        if val == "on":
            filters[attr] = True
        elif val == "off":
            filters[attr] = False

    for key, attr in [("has_texture", "rectified_normal__isnull"), ("has_reflectance", "bsdf_wd__isnull")]:
        val = request.REQUEST.get(key)
        if val == "on":
            filters[attr] = False

    order_by = request.REQUEST.get("order_by")
    if not order_by:
        order_by = "num_vertices"
    if "bsdf_wd" in order_by:
        filters["bsdf_wd__isnull"] = False
    if "rectified_normal" in order_by:
        filters["bsdf_wd__isnull"] = False

    entries = (
        MaterialShape.objects.filter(**filters)
        .order_by("-" + order_by)
        .select_related("photo", "photo__scene_category", "substance", "name", "bsdf_wd", "rectified_normal")
    )

    context = {
        "nav": "material-shape-search",
        "entries": entries,
        "thumb_template": "material_shape_row.html",
        "names": material_shape_categories(ShapeName),
        "substances": material_shape_categories(ShapeSubstance),
        "scene_categories": photo_scene_categories()["categories"],
    }

    context.update(extra_context)
    return render(request, template, context)
Example #2
0
def intrinsic_photo_all(request,
                        category_id='all',
                        filter_key='all',
                        template="intrinsic/photo_all.html",
                        extra_context=None):
    """ View judgements in images with each image taking up a block and the
    list of photo categories on the left """

    entries = Photo.objects.all()
    if category_id != 'all':
        category_id = int(category_id)
        entries = entries.filter(scene_category_id=category_id)

    entries = entries.filter(in_iiw_dataset=True) \
        .order_by('-num_intrinsic_comparisons') \
        .select_related(
            'intrinsic_comparisons',
            'intrinsic_comparisons__points',
            'intrinsic_points',
            'intrinsic_points__photo')

    context = {
        'iiw': True,
        'nav': 'browse/intrinsic-photo-all',
        'entries': entries,
        'category_id': category_id,
        'filter_key': 'all',
        'url_name': 'intrinsic-photo-all',
        'thumb_template': 'intrinsic/photo_entry.html',
        'span': 'span12',
        'entries_per_page': 4,
    }
    context.update(photo_scene_categories(in_iiw_dataset=True))
    context.update(extra_context)
    return render(request, template, context)
Example #3
0
def intrinsic_photo_all(
        request,
        category_id='all',
        filter_key='all',
        template="intrinsic/photo_all.html",
        extra_context=None):

    """ View judgements in images with each image taking up a block and the
    list of photo categories on the left """

    entries = Photo.objects.all()
    if category_id != 'all':
        category_id = int(category_id)
        entries = entries.filter(scene_category_id=category_id)

    entries = entries.filter(in_iiw_dataset=True) \
        .order_by('-num_intrinsic_comparisons') \
        .select_related(
            'intrinsic_comparisons',
            'intrinsic_comparisons__points',
            'intrinsic_points',
            'intrinsic_points__photo')

    context = {
        'iiw': True,
        'nav': 'browse/intrinsic-photo-all',
        'entries': entries,
        'category_id': category_id,
        'filter_key': 'all',
        'url_name': 'intrinsic-photo-all',
        'thumb_template': 'intrinsic/photo_entry.html',
        'span': 'span12',
        'entries_per_page': 4,
    }
    context.update(photo_scene_categories(in_iiw_dataset=True))
    context.update(extra_context)
    return render(request, template, context)
Example #4
0
def material_shape_search(request,
                          template='material_shape_search.html',
                          extra_context=None):

    filters = dict(MaterialShape.DEFAULT_FILTERS)

    if 'contrast' in request.REQUEST and request.REQUEST['contrast']:
        low, high = request.REQUEST['contrast'].split('-')
        if float(low) > 0:
            filters['bsdf_wd__contrast__gte'] = low
        if float(high) < 1:
            filters['bsdf_wd__contrast__lte'] = high

    if 'doi' in request.REQUEST and request.REQUEST['doi']:
        low, high = request.REQUEST['doi'].split('-')
        if int(low) > 0:
            filters['bsdf_wd__doi__gte'] = low
        if int(high) < 15:
            filters['bsdf_wd__doi__lte'] = high

    for key in ['substance', 'name', 'photo__scene_category']:
        id = request.REQUEST.get(key, 0)
        if id and int(id) > 0:
            filters[key + '_id'] = id

    for key, attr in [('planar', 'planar'),
                      ('whitebalanced', 'photo__whitebalanced')]:
        val = request.REQUEST.get(key)
        if val == 'on':
            filters[attr] = True
        elif val == 'off':
            filters[attr] = False

    for key, attr in [('has_texture', 'rectified_normal__isnull'),
                      ('has_reflectance', 'bsdf_wd__isnull')]:
        val = request.REQUEST.get(key)
        if val == 'on':
            filters[attr] = False

    order_by = request.REQUEST.get('order_by')
    if not order_by:
        order_by = 'num_vertices'
    if 'bsdf_wd' in order_by:
        filters['bsdf_wd__isnull'] = False
    if 'rectified_normal' in order_by:
        filters['bsdf_wd__isnull'] = False

    entries = MaterialShape.objects \
        .filter(**filters) \
        .order_by('-' + order_by) \
        .select_related(
            'photo', 'photo__scene_category', 'substance',
            'name', 'bsdf_wd', 'rectified_normal'
        )

    context = {
        'nav': 'material-shape-search',
        'entries': entries,
        'thumb_template': 'material_shape_row.html',
        'names': material_shape_categories(ShapeName),
        'substances': material_shape_categories(ShapeSubstance),
        'scene_categories': photo_scene_categories()['categories'],
    }

    context.update(extra_context)
    return render(request, template, context)