Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open file, path = '..assets/images/bunny.jpg' (OS Error: No such file or directory, errno = 2) , EVEN THOUGH I HAVE TESTED IMAGES FROM TESTED FOLDER IT IS SHOWING AND READING IN IMAGE.FILE #11

Open
RehanNG opened this issue Mar 2, 2023 · 3 comments
Assignees

Comments

@RehanNG
Copy link

RehanNG commented Mar 2, 2023

ERROR
E/flutter (23739): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PathNotFoundException: Cannot open file, path = '..assets/images/bunny.jpg' (OS Error: No such file or directory, errno = 2)

CODE
import 'dart:typed_data';
//tested working
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:image_compare/image_compare.dart';
//https://pub.dev/packages/image_compare
class testScreen extends StatefulWidget {
// const testScreen({Key? key}) : super(key: key);

@OverRide
State createState() => testScreenState();
}

class testScreenState extends State {
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Center(
child: Center(
child: Padding(
padding: const EdgeInsets.only(top: 60),
child: Column(

        children: <Widget>[
          IconButton(onPressed: () async{

            ImageCompare();


          }, icon: Center(child: Icon(Icons.ac_unit)) ),


          Image.asset(
            'assets/images/bunny.jpg',
            height: 400,
            width: 400,
          ),



          
          
        ],

      ),
    ),
  ),
),

),
);
}
}

//this is one image compare async mehod
void ImageCompare() async{

// var url1 = Uri.parse('https://www.tompetty.com/sites/g/files/g2000007521/f/sample_01.jpg');
// var url2 = Uri.parse('https://www.tompetty.com/sites/g/files/g2000007521/f/sample_01.jpg');
// var url2 = 'https://fujifilm-x.com/wp-content/uploads/2019/08/x-t30_sample-images03.jpg';

//jpg ko recognize kar reha ha , jpg pa response da reha ha
// png ko koi algrithm bh recognize nai kar reha

//working
var a = Uri.parse('https://fujifilm-x.com/wp-content/uploads/2019/08/x-t30_sample-images03.jpg');
var aS = Uri.parse('https://fujifilm-x.com/wp-content/uploads/2019/08/x-t30_sample-images03.jpg');
var c = Uri.parse('https://hs.sbcounty.gov/cn/Photo%20Gallery/Sample%20Picture%20-%20Koala.jpg');

//not working
var d_discard_png_not_recognizing = Uri.parse('https://github.com/nitinramadoss/image_compare/blob/main/images/seven2.PNG');
var e_discard_png_not_recognizing = Uri.parse('https://github.com/nitinramadoss/image_compare/blob/main/images/seven.PNG');

//not working (because ya temporary directory ( sxGKm5wK ) bna reha ha jis ke wejha sa direct image detect nai kar reha )

dynamic f = Uri.parse('https://i.postimg.cc/sxGKm5wK/bunny.jpg');
dynamic g = Uri.parse('https://i.postimg.cc/kMVdzZHY/deer.jpg');

// https://images.unsplash.com/photo-1592029383200-73fb26a5b925?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1160&q=80

//unsplash Working (because ya temporary directory nai bna reha ha jis ke wejha sa direct image detect kar reha)
var unsplash_pic_1 = Uri.parse('https://images.unsplash.com/photo-1592029383200-73fb26a5b925?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1160&q=80');
var unsplash_pic_1_same_compare = Uri.parse('https://images.unsplash.com/photo-1592029383200-73fb26a5b925?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1160&q=80');
var unsplash_pic_2 = Uri.parse('https://images.unsplash.com/photo-1613681230409-6423a38c43e1?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1742&q=80');

//google image test

//not working (because ya temporary directory ( sxGKm5wK ) bna reha ha jis ke wejha sa direct image detect nai kar reha )
var google_drive_image_t1 = Uri.parse('https://drive.google.com/file/d/1PkTtgQTeNi0Ss0GSeYBaK82rYEs_ed4O');
var google_drive_image_t2 = Uri.parse('https://drive.google.com/file/d/1PkTtgQTeNi0Ss0GSeYBaK82rYEs_ed4O');

//firebase test (I dont know why it is working but it is giving response )

//https://firebasestorage.googleapis.com/v0/b/face-liveness-detector.appspot.com/o/images%2FuserID%3A1%3Arehan?alt=media&token=8b214d4c-cf8a-4134-8b2e-91355f4b5c6a
var firebase_image_t1 = Uri.parse('https://firebasestorage.googleapis.com/v0/b/face-liveness-detector.appspot.com/o/images%2FuserID%3A1%3Arehan?alt=media&token=8b214d4c-cf8a-4134-8b2e-91355f4b5c6a');
var firebase_image_t2 = Uri.parse('https://firebasestorage.googleapis.com/v0/b/face-liveness-detector.appspot.com/o/images%2FuserID%3A12%3Awajahat?alt=media&token=3a9b3e61-0cf7-474f-93cc-9db99a06e1b7');
var firebase_image_t2_different_expression = Uri.parse('https://firebasestorage.googleapis.com/v0/b/face-liveness-detector.appspot.com/o/images%2FuserID%3A1%3Arehan?alt=media&token=8b214d4c-cf8a-4134-8b2e-91355f4b5c6a');
var firebase_image_t1_same = Uri.parse('https://firebasestorage.googleapis.com/v0/b/face-liveness-detector.appspot.com/o/images%2FuserID%3A1%3Arehan?alt=media&token=8b214d4c-cf8a-4134-8b2e-91355f4b5c6a');

//File tesing
//
//this format not working
// String? imagePath1='- assets/images/bunny.jpg';
// String? imagePath2='- assets/images/deer.jpg';

//not working
// String? imagePath1_format_diferent='images/bunny.jpg';
// String? imagePath2_format_diferent='images/bunny.jpg';

//not working
// var file_1 = File('$imagePath1_format_diferent');
// var file_2 = File('$imagePath2_format_diferent');

// print(' Ya rahe file nicha liabrary support nai kar rahe $file_1');

// Calculate euclidean color distance between two images
// EuclideanColorDistance( ignoreAlpha: true ) - tested - problem : diference problem
// File

/*
Image.asset(
'assets/images/bunny.jpg',
height: 400,
width: 400,
);*/

File File1 = File('..assets/images/bunny.jpg');
var imageResult = await compareImages(src1: /firebase_image_t1/File1, src2: firebase_image_t2 , algorithm: /EuclideanColorDistance( ignoreAlpha: true )/PerceptualHash() );

print('Difference Wala Response A reha ha Aur wo ya ha : ${imageResult * 100}%');
//ya double main value return kar reha ha

// IF KE LOGIC FOR EuclideanColorDistance( ignoreAlpha: true )
//ager difference 0.0% ha to image match kar rahe ha , ager zara sa bhe difference a reha ha to image match nai kar rahe

/*

1)EuclideanColorDistance({bool ignoreAlpha = true}) #

About
Images are resized to the same dimensions (if dimensions don't match) and euclidean difference between [src1] RGB values and [src2] RGB values for each pixel is summed.
Best with images of similar aspect ratios and dimensions
Compare for exactness (if two images are identical)

PerceptualHash(),
If you want to compare two images, construct the hash from each image and count the
number of bit positions that are different. ( This is a Hamming distance. )
A distance of zero indicates that it is likely a very similar picture
(or a variation of the same picture).

A distance of 5 means a few things may

be different, but they are probably
still close enough to be similar.

But a distance of 10 or more? That's probably a very different picture.

/
/

LIABRARY ERRORS

E/flutter ( 3517): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: The source, String, passed in is unsupported

TYPE IMAGE HA JO A RAHE HA (ERROR DESCRIPTION)
/C:/Users/Developer/AppData/Local/Pub/Cache/hosted/pub.dev/image_compare-1.1.2/lib/src/functions.dart:22:10: Error: A value of type 'Image' can't be assigned to a variable of type 'String'.

IMAGE KE AIK CLASS USE HO RAHE HA , AUR AUS CLASS MAIN DATA int MAIN MAIN PROCESS HO REHA HA
class Image {
/// Width of the image.
final int width;

/// Height of the image.
final int height;
}

*/

}

MY REQUEST

Kindly Fix This Issue as soon as possible because this is good library and have potential to grow please fix this file comparison issue and make proper and complete documentation , on how to compare File to File , File to url and others ,

Kind Regards,
Rehan.

@krlaa
Copy link
Collaborator

krlaa commented Mar 4, 2023

Hi @RehanNG,

First off thank you for speaking kindly about our package! We can certainly try to help you with this issue. Can you provide us with more information such as which build target you are using this for? Is it flutter web, mobile, or desktop that you run into this issue?

@krlaa krlaa closed this as completed Mar 4, 2023
@krlaa krlaa reopened this Mar 4, 2023
@RehanNG
Copy link
Author

RehanNG commented Mar 6, 2023

Hello Thanks for replying and collaborating , I am using mobile , If You say so I can email you my complete source pages to diagnose , because I tried every thing like to compare single image url with list of urls and many more formats , the only one which are working are mentioned in my comments , please provide me a working solution for this issue,

Kind Regards,
Rehan.

@AminMemariani
Copy link

AminMemariani commented Jun 2, 2023

Same problem here,
I tried it on iPhone 14 Pro Max and it gave me this error:
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: FileSystemException: Cannot open file, path = '../images/animals/koala.jpg' (OS Error: No such file or directory, errno = 2)
I just tried to run the example code. The error fired on readAsBytesSync() function call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants