FORUMS
Remove All Ads from XDA

Cameras from CM10.2/AOSP with SD support and geotags/timestamp in Exif

106 posts
Thanks Meter: 24
 
Post Reply Email Thread
upd:The problem below affects some devices like Motorola Razr or Galaxy S3 Mini and is caused by camera driver.

Hello. Recently i've been crying all around the internet that camera doesn't include gps info in exif tags.
Nobody helped me, so i built camera from source in android studio. Used xmpCore and mp4parser.

13-08-15: Added 2 lines in PhotoModule.java:
Code:
                        exif.setTag(directionTag);
                    }
                    if(mLocation != null)
                        exif.addGpsTags(mLocation.getLatitude(), mLocation.getLongitude());
                    mActivity.getMediaSaveService().addImage(
Also changed everywhere
Code:
import android.support.v8.renderscript<...>
And in VideoUtils.java:
Code:
IsoFile out = (IsoFile)new DefaultMp4Builder().build(movie);
UPD 13-08-20: user The_ERROR asked for date/time stamp in exif, so i updated the app. PhotoModule.java new changes:
Code:
79a80
> import java.util.TimeZone;
864c865
<                     if(mLocation != null)
---
>                     if(mLocation != null) {
865a867,869
>                         exif.addGpsDateTimeStampTag(date);
>                     }
>                     exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, date, TimeZone.getDefault());
UPD 13-08-22: No more crashes on clicking "Show on map" menu item if google maps not installed. GalleryUtils.java:
Code:
284a285
>             if(!checkActivityFound(context, mapsIntent)) throw new ActivityNotFoundException();
291c292
<             context.startActivity(mapsIntent);
---
>             if(checkActivityFound(context, mapsIntent)) context.startActivity(mapsIntent);
294a296,301
>     private static boolean checkActivityFound(Context context, Intent intent) {
>         List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
>                                                                 PackageManager.MATCH_DEFAULT_ONLY);
>         return list.size() > 0;
>     }
>
UPD 13-08-23: Super cool things happen! I managed to compile CM10.2 camera with internal/external storage location option even before official nightly:P And integrated all my changes in it. Checked on CM10.2. It works.
Reopen camera after changing storage location or sliding right>left you will list photos from previous location. Though new photos go to the right one anyway.

Remove standard gallery2 using smth like RootAppDelete or ES file explorer and reboot before installing. I tried this app in CM10.1, CM10.2.
Attached Files
File Type: 7z gallery2_gps_src_130822.7z - [Click for QR Code] (4.87 MB, 42 views)
File Type: apk Gallery2.apk - [Click for QR Code] (6.34 MB, 66 views)
File Type: apk CM10.2_Gallery2_130823.apk - [Click for QR Code] (6.41 MB, 103 views)
The Following 7 Users Say Thank You to andray For This Useful Post: [ View ] Gift andray Ad-Free
 
 
19th August 2013, 10:19 PM |#2  
The_ERROR's Avatar
Senior Member
Flag Ostrava (mostly)
Thanks Meter: 364
 
More
Quote:
Originally Posted by andray

Hello. Recently i've been crying all around the internet that camera doesn't include gps info in exif tags.
Nobody helped me, so i built camera from source in android studio. .....

amazing... I'm forcing similar problem, but I would like to have some kind of timestamp in EXIF data as well. Do you thing, that it would be possible to add it into your compiled version?
20th August 2013, 08:48 AM |#3  
OP Senior Member
Flag Zheleznodorozhny
Thanks Meter: 24
 
Donate to Me
More
I'm at work now, so cannot try anything, but i see two auxiliary functions in ExifInterface.java

Code:
    /**
     * Creates, formats, and sets the DateTimeStamp tag for one of:
     * {@link #TAG_DATE_TIME}, {@link #TAG_DATE_TIME_DIGITIZED},
     * {@link #TAG_DATE_TIME_ORIGINAL}.
     *
     *  @param tagId one of the DateTimeStamp tags.
     *  @param timestamp a timestamp to format.
     *  @param timezone a TimeZone object.
     *  @return true if success, false if the tag could not be set.
     */
    public boolean addDateTimeStampTag(int tagId, long timestamp, TimeZone timezone) {
        if (tagId == TAG_DATE_TIME || tagId == TAG_DATE_TIME_DIGITIZED
                || tagId == TAG_DATE_TIME_ORIGINAL) {
            mDateTimeStampFormat.setTimeZone(timezone);
            ExifTag t = buildTag(tagId, mDateTimeStampFormat.format(timestamp));
            if (t == null) {
                return false;
            }
            setTag(t);
        } else {
            return false;
        }
        return true;
    }

    /**
     * Creates and sets the GPS timestamp tag.
     *
     *  @param timestamp a GPS timestamp.
     *  @return true if success, false if could not be created or set.
     */
    public boolean addGpsDateTimeStampTag(long timestamp) {
        ExifTag t = buildTag(TAG_GPS_DATE_STAMP, mGPSDateStampFormat.format(timestamp));
        if (t == null) {
            return false;
        }
        setTag(t);
        mGPSTimeStampCalendar.setTimeInMillis(timestamp);
        t = buildTag(TAG_GPS_TIME_STAMP, new Rational[] {
                new Rational(mGPSTimeStampCalendar.get(Calendar.HOUR_OF_DAY), 1),
                new Rational(mGPSTimeStampCalendar.get(Calendar.MINUTE), 1),
                new Rational(mGPSTimeStampCalendar.get(Calendar.SECOND), 1)
        });
        if (t == null) {
            return false;
        }
        setTag(t);
        return true;
    }

and in PanoramaModule.java
Code:
                exif.addGpsDateTimeStampTag(mTimeTaken);
                exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, mTimeTaken,
                        TimeZone.getDefault());
The Following User Says Thank You to andray For This Useful Post: [ View ] Gift andray Ad-Free
20th August 2013, 11:31 AM |#4  
OP Senior Member
Flag Zheleznodorozhny
Thanks Meter: 24
 
Donate to Me
More
Lightbulb
Quote:
Originally Posted by The_ERROR

amazing... I'm forcing similar problem, but I would like to have some kind of timestamp in EXIF data as well. Do you thing, that it would be possible to add it into your compiled version?

Ok. I did this. Here're new exif fields according to Jeffrey's Exif viewer, date/time fields are bold. If geo-location is turned off in Camera, only "Modify Date" tag will be added.
GPS Latitude Ref
GPS Latitude
GPS Longitude Ref
GPS Longitude
GPS Time Stamp
GPS Date Stamp
Modify Date
A patch of PhotoModule.java:
Code:
79a80
> import java.util.TimeZone;
864c865
<                     if(mLocation != null)
---
>                     if(mLocation != null) {
865a867,869
>                         exif.addGpsDateTimeStampTag(date);
>                     }
>                     exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, date, TimeZone.getDefault());

I'll update first post now
The Following User Says Thank You to andray For This Useful Post: [ View ] Gift andray Ad-Free
22nd August 2013, 02:25 PM |#5  
The_ERROR's Avatar
Senior Member
Flag Ostrava (mostly)
Thanks Meter: 364
 
More
Is there way how to chose default storage for photo? I'm not able to find it.
22nd August 2013, 08:23 PM |#6  
OP Senior Member
Flag Zheleznodorozhny
Thanks Meter: 24
 
Donate to Me
More
I think storage settings will be included in next CM10.2 nigthly http://review.cyanogenmod.org/#/c/47623/ Storage location configuration options
The bad thing - i used AOSP sources.)

By the way, i patched camera sources to not crash on clicking "Show on map" menu item if google maps not installed. GalleryUtils.java:
Code:
284a285
>             if(!checkActivityFound(context, mapsIntent)) throw new ActivityNotFoundException();
291c292
<             context.startActivity(mapsIntent);
---
>             if(checkActivityFound(context, mapsIntent)) context.startActivity(mapsIntent);
294a296,301
>     private static boolean checkActivityFound(Context context, Intent intent) {
>         List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
>                                                                 PackageManager.MATCH_DEFAULT_ONLY);
>         return list.size() > 0;
>     }
>
23rd August 2013, 01:01 PM |#7  
OP Senior Member
Flag Zheleznodorozhny
Thanks Meter: 24
 
Donate to Me
More
Quote:
Originally Posted by The_ERROR

Is there way how to chose default storage for photo? I'm not able to find it.

Woo-hoo! Now we can choose default storage! Read first post.
23rd August 2013, 04:51 PM |#8  
anerik's Avatar
Senior Member
Flag La Plata
Thanks Meter: 3,478
 
More
Thanks for this! Been looking for it
EDIT: FCs on razr i when i open camera, cm version
23rd August 2013, 06:24 PM |#9  
OP Senior Member
Flag Zheleznodorozhny
Thanks Meter: 24
 
Donate to Me
More
Quote:
Originally Posted by anerik

EDIT: FCs on razr i when i open camera, cm version

CM version WHICH? As for me, camera FCs 2-3 times after install on cm10.1/2. This version or standard one, no matter. I have razr maxx only.
23rd August 2013, 06:36 PM |#10  
anerik's Avatar
Senior Member
Flag La Plata
Thanks Meter: 3,478
 
More
Quote:
Originally Posted by andray

CM version WHICH? As for me, camera FCs 2-3 times after install on cm10.1/2. This version or standard one, no matter. I have razr maxx only.

not runnin cm, i mean the cm gallery u uploaded gives me fc when i open the camera
23rd August 2013, 06:53 PM |#11  
OP Senior Member
Flag Zheleznodorozhny
Thanks Meter: 24
 
Donate to Me
More
Quote:
Originally Posted by anerik

not runnin cm, i mean the cm gallery u uploaded gives me fc when i open the camera

ok. you can check what's going on in using Logcat Extreme. I don't know ur android version, but 4.0 is not enough. i've tried now gallery works, camera fcs

upd: AOSP version fully works on android 4.0
Post Reply Subscribe to Thread

Tags
camera, exif, gps

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes