Take pictures secretly (without preview or launching device's camera app) from all available cameras using Android CAMERA2 API.The Camera2 API replaces the deprecated Camera class.
PictureCapturingListener
(your capture listener) and override the following methods:
APictureCapturingService
using PictureCapturingServiceImpl#getInstance()
method;APictureCapturingService#startCapturing(PictureCapturingListener listener)
and pass the listener you've just implemented (step 1)Here, I've chosen to just display the two pictures taken within a vertical linear layout. Here is a code snippet of how to use the service:
public class MainActivity extends AppCompatActivity implements PictureCapturingListener, ActivityCompat.OnRequestPermissionsResultCallback {
private APictureCapturingService pictureService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//check for camera and external storage permissions
checkPermissions();
final Button btn = (Button) findViewById(R.id.startCaptureBtn);
pictureService = PictureCapturingServiceImpl.getInstance(this);
//start capturing when clicking on the button
btn.setOnClickListener(v ->
pictureService.startCapturing(this)
);
}
@Override
public void onDoneCapturingAllPhotos(TreeMap<String, byte[]> picturesTaken) {
if (picturesTaken != null && !picturesTaken.isEmpty()) {
picturesTaken.forEach((pictureUrl, pictureData) -> {
//convert the byte array 'pictureData' to a bitmap (no need to read the file from the external storage) but in case you
//You can also use 'pictureUrl' which stores the picture's location on the device
final Bitmap bitmap = BitmapFactory.decodeByteArray(pictureData, 0, pictureData.length);
});
showToast("Done capturing all photos!");
return;
}
showToast("No camera detected!");
}
@Override
public void onCaptureDone(String pictureUrl, byte[] pictureData) {
if (pictureData != null && pictureUrl != null) {
runOnUiThread(() -> {
//convert byte array 'pictureData' to a bitmap (no need to read the file from the external storage)
final Bitmap bitmap = BitmapFactory.decodeByteArray(pictureData, 0, pictureData.length);
//scale image to avoid POTENTIAL "Bitmap too large to be uploaded into a texture" when displaying into an ImageView
final int nh = (int) (bitmap.getHeight() * (512.0 / bitmap.getWidth()));
final Bitmap scaled = Bitmap.createScaledBitmap(bitmap, 512, nh, true);
//do whatever you want with the bitmap or the scaled one...
});
showToast("Picture saved to " + pictureUrl);
}
}
private void showToast(final String text) {
runOnUiThread(() ->
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show()
);
}
}
Thanks to maaudrana for the logo :)
Hamed ZITOUN zitoun.hamed@gmail.com
If you run into issues, please don't hesitate to find help on the GitHub project.
The android-camera2-secret-picture-taker is covered by the MIT License.
The MIT License (MIT)
Copyright (c) 2021 Hamed ZITOUN and contributors to the android-camera2-secret-picture-taker project.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
描述 复杂的图片组件 在 Weex 容器中,Picture 和 Image 组件只有 forceUpdate 属性不同 安装 $ npm install rax-picture --save 属性 属性 类型 默认值 必填 描述 支持 source Object: {uri: String} - ✔️ 设置图片的 uri style Object: { width: Number height:
问题内容: 我正在使用OnImageAvailableListener获得预览帧: 每次数据长度不同,但图像的宽度和高度相同。 主要问题:对于3264x2448之类的分辨率而言太小。 数据数组的大小应为3264 * 2448 = 7,990,272,而不是300,000-600,000。 怎么了? 问题答案: 我通过使用 YUV_420_888 图像格式并将其手动转换为 JPEG 图像格式解决了此
Picture cut 是一个 jQuery 插件,通过友好的方式实现漂亮的图像上传、浏览和剪切操作。 特性: Ajax 上传 图像大小调整 拖放图片实现上传 图像尺寸处理 图像裁剪 支持浏览器: Google Chrome Mozilla Firefox Apple Safari Opera Internet Explorer 7+
开源图床: 出于自用的目的,又找不到Java写的开源的程序,然后使用开源上传组件 bootstrap-fileinput 用 Spring Boot 写了一个图床,目前支持:七牛云,阿里云 Configuration 使用的时候需要按照application.properties 里面的注释配置即可
我正在编写一个简单的Android应用程序,在该应用程序中,我使用ImageReader.onImageAvailableListener检索帧缓冲区,以获取最新的图像并处理Y平面。我使用这个平面来计算一个简单的度量,它的值将决定我是否在屏幕上显示某些东西。 我的问题是如何只处理和解释Y平面(我不需要U和V平面)。根据我的理解,Y平面包含亮度通道;即图像亮度的通道。 我的问题是,这些亮度值应该如何
Secret解决了密码、token、密钥等敏感数据的配置问题,而不需要把这些敏感数据暴露到镜像或者Pod Spec中。Secret可以以Volume或者环境变量的方式使用。 Secret有三种类型: Service Account :用来访问Kubernetes API,由Kubernetes自动创建,并且会自动挂载到Pod的/run/secrets/kubernetes.io/serviceac