Update mobileapp.txt
Browse files- mobileapp.txt +18 -56
mobileapp.txt
CHANGED
@@ -1,62 +1,24 @@
|
|
1 |
-
import
|
2 |
-
import
|
3 |
-
import * as ImagePicker from 'expo-image-picker';
|
4 |
-
import { ImageEditor } from 'react-native';
|
5 |
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
if (status !== 'granted') {
|
16 |
-
alert('Permission denied!');
|
17 |
-
}
|
18 |
-
};
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
});
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
}
|
28 |
-
};
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
displaySize: { width: 200, height: 200 }, // desired width, height of the cropped image
|
35 |
-
resizeMode: 'contain', // resizing mode
|
36 |
-
};
|
37 |
-
|
38 |
-
ImageEditor.cropImage(
|
39 |
-
imageUri,
|
40 |
-
cropData,
|
41 |
-
(croppedURI) => {
|
42 |
-
// Handle the cropped image URI
|
43 |
-
console.log('Cropped image URI:', croppedURI);
|
44 |
-
setCroppedImage({ uri: croppedURI });
|
45 |
-
},
|
46 |
-
(error) => {
|
47 |
-
console.error('Error cropping image:', error);
|
48 |
-
}
|
49 |
-
);
|
50 |
-
};
|
51 |
-
|
52 |
-
return (
|
53 |
-
<View>
|
54 |
-
<TouchableOpacity onPress={handleSelectImage}>
|
55 |
-
<Text>Select Image</Text>
|
56 |
-
</TouchableOpacity>
|
57 |
-
{croppedImage && <Image source={croppedImage} style={{ width: 200, height: 200 }} />}
|
58 |
-
</View>
|
59 |
-
);
|
60 |
-
};
|
61 |
-
|
62 |
-
export default CropImage;
|
|
|
1 |
+
import cv2
|
2 |
+
import numpy as np
|
|
|
|
|
3 |
|
4 |
+
# Load the image (assuming it's a binary image with edges)
|
5 |
+
image = cv2.imread('path/to/edge_detected_image.jpg', cv2.IMREAD_GRAYSCALE)
|
6 |
|
7 |
+
# Apply morphological operations to clean up the edges
|
8 |
+
kernel = np.ones((5, 5), np.uint8)
|
9 |
+
closed_image = cv2.morphologyEx(image, cv2.MORPH_CLOSE, kernel)
|
10 |
|
11 |
+
# Find contours in the closed image
|
12 |
+
contours, _ = cv2.findContours(closed_image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
# Create a mask for the exterior contours
|
15 |
+
mask = np.zeros_like(image)
|
16 |
+
cv2.drawContours(mask, contours, -1, (255), thickness=cv2.FILLED)
|
|
|
17 |
|
18 |
+
# Apply the mask to the original image to get only the exterior edges
|
19 |
+
exterior_edges = cv2.bitwise_and(image, mask)
|
|
|
|
|
20 |
|
21 |
+
# Display the result or save it to a file
|
22 |
+
cv2.imshow('Exterior Edges', exterior_edges)
|
23 |
+
cv2.waitKey(0)
|
24 |
+
cv2.destroyAllWindows()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|