kritzikratzi / edsdk4j

Canon SDK for Java
Other
109 stars 33 forks source link

Cam detection in Win 64 bit machine #16

Closed Chaithanya-Bangaru closed 9 years ago

Chaithanya-Bangaru commented 9 years ago

Hello, Am unable to get the canon 600d cam detected in Windows 7 64 bit machine although it worked with my Win 7 32 bit machine, tried with using JDK 6 and 7, Do you have any info of which systems are supporting this edsdk4j api, I know canon cam is compatible with Windows 7. Pre Java 7 file:// is correct, and in java 7 or more is file:/// , Is this correct statement Hans?

SteveHodge commented 9 years ago

Are you using the 64bit SDK?

Chaithanya-Bangaru commented 9 years ago

Thanks for response, Just found that am using 32 bit JVM for building the application, As canon 600D is Win 7 compatible, Do you think if i build my web app with 64 bit jvm, that works for both 32 bit and 64 bit Win 7 machines ?

Chaithanya-Bangaru commented 9 years ago

Also I see, below code in CanonCamera.java, Do you think any changes can be made to support both 32 bit and 64 bit ? because when I checked in 64 bit machine, (when you see the last line below) the applet console is showing cannot find the DLL as its going into 32 bit if block as given below, if ( url != null ) { try { // handle unc paths (pre java7 :/ ) URI uri = url.toURI(); if( uri.getAuthority() != null && uri.getAuthority().length() > 0 ){ uri = new URL("file://" + url.toString().substring(5)).toURI(); } final File file = new File( uri ); final String dir = file.getParentFile().getPath(); System.setProperty( "jna.library.path", dir ); //System.out.println("jna.library.path: "+dir); } catch ( final Exception e ) { e.printStackTrace(); } } if ( arch != null && arch.endsWith( "64" ) ) { edsdkDllLoc = "EDSDK_64/EDSDK.dll"; } else { edsdkDllLoc = "EDSDK/Dll/EDSDK.dll"; // going into this block in 64 bit machine }

kritzikratzi commented 9 years ago

afaik 64 bit canon sdk is still experimental. i'd sugget using the 32bit version in all cases. just start the jvm with -d32.

Chaithanya-Bangaru commented 9 years ago

Thanks, So starting jvm with -d32, Can I remove this condition in CanonCamera.java ? if ( arch != null && arch.endsWith( "64" ) ) {

kritzikratzi commented 9 years ago

imho yes

Chaithanya-Bangaru commented 9 years ago

Tried with that Hans, did not work, edsdk4j is not getting recognized, but java console is not giving any error, may be I need to test more.. But, I've found a bug in CanonCamera.java in identifying the underlined OS, Bug : In some of 64 bit machines above condition is showing as 32 bit, and the fix is below which worked:

            String arch = System.getenv("PROCESSOR_ARCHITECTURE");
    String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");

    String realArch = arch.endsWith("64") || wow64Arch != null 
                        && wow64Arch.endsWith("64") ? "64" : "32";
        if ( arch != null && arch.endsWith( "64" ) ) {
               edsdkDllLoc = "EDSDK_64/EDSDK.dll";
        } else {
               edsdkDllLoc = "EDSDK2/Dll/EDSDK.dll"; 
            }

If you've found to get canon recognize in 64 bit machine, Please share ideas..Thanks.

kritzikratzi commented 9 years ago

i think thats not right.

PROCESSOR_ARCHITECTURE and PROCESSOR_ARCHITEW6432 contain the architecture of the operating system, while os.arch contains the architecture of the java process. this is an important difference and your code above will go horribly wrong if 32bit java is running on a 64 bit operating system.

it should be rather simple really: drag two the two folders, EDSDK and EDSDK_64, into your project, and press start.

if os.arch reports 32 bit then it means you are using 32bit java.
if you want to force bitness you should launch with the java processing with the -d64 or -d32 option, but you may get an error that tells you have to download a new jre. (it's possible you only have 32 or 64 bit installed, make sure to get the right one).

ideally you just support both.