Click here to Skip to main content
16,022,309 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am working on a python Flask project, in where the core idea is to verify the image uploaded by the user and make sure it's not fake or they are plagiarized.

The help i need regarding is - User uploads the pic of a plant , i want to make sure that , they have only taken the picture, not from internet or copied from another person in the same platform. I have some preliminary checks but they are not enough, can anyone advise me on what more can i do ? I have done these mentioned below:

A) Done image quality check

B) Web detection

C)Database duplicate detection

D)Using latitude and longitude (failed miserably, accuracy difference of 2KM)

E)Making sure the image is plant only

Since the location method is not working, i have that loophole, i don't need it to be super security level but as long something similar to accurate location detection or any similar technique to make sure the image is really from the user. Would love to have some advise. Below is the location extracting code from image uploaded. Thankyou !

What I have tried:

# EXIF extraction functions
def get_exif_data(image_path):
    """Get embedded EXIF data from image file using ExifRead."""
    with open(image_path, 'rb') as image_file:
        tags = exifread.process_file(image_file)
    return tags

def get_gps_data(tags):
    """Extract GPS data from EXIF tags."""
    gps_data = {}
    gps_keys = ['GPS GPSLatitude', 'GPS GPSLatitudeRef', 'GPS GPSLongitude', 'GPS GPSLongitudeRef']
    for key in gps_keys:
        if key in tags:
            gps_data[key] = tags[key]
    return gps_data

def convert_to_degrees(value):
    """Convert GPS coordinates to degrees, avoiding zero division."""
    def safe_div(num, den):
        return float(num) / float(den) if den != 0 else 0

    if len(value.values) != 3:
        print("Incomplete GPS coordinate data.")
        return None

    d = safe_div(value.values[0].num, value.values[0].den)
    m = safe_div(value.values[1].num, value.values[1].den)
    s = safe_div(value.values[2].num, value.values[2].den)
    return d + (m / 60.0) + (s / 3600.0)

def get_lat_lon(gps_data):
    """Extract latitude and longitude from GPS data."""
    lat = None
    lon = None

    gps_latitude = gps_data.get('GPS GPSLatitude')
    gps_latitude_ref = gps_data.get('GPS GPSLatitudeRef')
    gps_longitude = gps_data.get('GPS GPSLongitude')
    gps_longitude_ref = gps_data.get('GPS GPSLongitudeRef')

    if gps_latitude and gps_latitude_ref and gps_longitude and gps_longitude_ref:
        lat = convert_to_degrees(gps_latitude)
        lon = convert_to_degrees(gps_longitude)

        if lat is None or lon is None:
            return None, None

        if gps_latitude_ref.values[0] != 'N':
            lat = -lat
        if gps_longitude_ref.values[0] != 'E':
            lon = -lon

    return lat, lon

def extract_gps_from_image(image_path):
    tags = get_exif_data(image_path)
    gps_data = get_gps_data(tags)
    lat, lon = get_lat_lon(gps_data)
    return lat, lon
Posted

1 solution

Location checking is a useless technique I'm afraid. I like to travel, and I like to take photographs. Unless I was uploading the image to you instantly, the chances of matching the image location to my location are pretty much zero.

What is the problem you're attempting to solve here? Why do you need to know if the image is unique? The amount of effort you are going to have to expend here needs to be worth the problem you're solving.
 
Share this answer
 
Comments
Preran S Gowda 2-Jun-24 6:18am    
actually i am trying to build a app where user can post about taking care of their plants from sapling stage to growth stage over a span of time and i want to avoid things like person A takes care of plant and person B comes to his house and takes photo and uploads it, assuming person A is already a member of my platform and is uploading those pics of same plant. So anyway i can solve it ?
Pete O'Hanlon 2-Jun-24 6:38am    
I don't think you can solve this problem. Suppose my neighbour and I both have alpine herbs, and we grow them on opposite sides of a fence. How could you tell which was mine, and which my neighbours? Even image recognition isn't going to help you.

The best you could do is probably going to be a report image option, and that's assuming you have people ready to deal with the deduplication remediation effort.
Preran S Gowda 2-Jun-24 7:28am    
For unique conditions like that we will use man power, its not like all 1000/1000 photos will be like that, can you advise on the best methods i can use to overcome this problem ? i do not want it to be perfect, as long as it is presentable i am okay with it.
Pete O'Hanlon 2-Jun-24 9:36am    
Honestly, the admittedly sucking location you currently have, there's not a lot more you can do. You could combine the location with the genus to pick possible matches, but that's as close as you are likely to get.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900