我在想什么?
我试图用可绘画/油漆在脸上拍照,但是,我无法在同一张照片上同时拍摄.
我试过了什么?
我尝试过使用,CameraSource.takePicture
但我只是脸上没有任何可绘画/油漆.
mCameraSource.takePicture(shutterCallback, new CameraSource.PictureCallback() {
@Override
public void onPictureTaken(byte[] bytes) {
try {
String mainpath = getExternalStorageDirectory() + separator + "TestXyz" + separator + "images" + separator;
File basePath = new File(mainpath);
if (!basePath.exists())
Log.d("CAPTURE_BASE_PATH", basePath.mkdirs() ? "Success": "Failed");
String path = mainpath + "photo_" + getPhotoTime() + ".jpg";
File captureFile = new File(path);
captureFile.createNewFile();
if (!captureFile.exists())
Log.d("CAPTURE_FILE_PATH", captureFile.createNewFile() ? "Success": "Failed");
FileOutputStream stream = new FileOutputStream(captureFile);
stream.write(bytes);
stream.flush();
stream.close();
} catch (IOException e) { …
Run Code Online (Sandbox Code Playgroud) 我试图使用VNDetectFaceRectanglesRequest
新的Vision
API来检测图像上的面.然后,我在每个检测到的脸上画一个红色矩形.
但我有一个问题,boundingBox
从VNFaceObservation
转换为CGRect
.似乎我唯一的问题是y起源.
这是我的代码:
let request=VNDetectFaceRectanglesRequest{request, error in
var final_image=UIImage(ciImage: image)
if let results=request.results as? [VNFaceObservation]{
for face_obs in results{
UIGraphicsBeginImageContextWithOptions(final_image.size, false, 1.0)
final_image.draw(in: CGRect(x: 0, y: 0, width: final_image.size.width, height: final_image.size.height))
var rect=face_obs.boundingBox
/*/*/*/ RESULT 2 is when I uncomment this line to "flip" the y /*/*/*/
//rect.origin.y=1-rect.origin.y
let conv_rect=CGRect(x: rect.origin.x*final_image.size.width, y: rect.origin.y*final_image.size.height, width: rect.width*final_image.size.width, height: rect.height*final_image.size.height)
let c=UIGraphicsGetCurrentContext()!
c.setStrokeColor(UIColor.red.cgColor)
c.setLineWidth(0.01*final_image.size.width)
c.stroke(conv_rect)
let result=UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
final_image=result!
}
} …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Microsoft 认知服务的 Vision API(分析图像)。我想知道如何通过 REST API 调用将本地图像发送到 Vision API,并使用 Python 请求结果。有人可以帮我解决这个问题吗?
Microsoft 在其网站上提供的测试选项仅接受 URL,我尝试将本地路径转换为 URL 并将其作为输入,但这不起作用。
我必须在 Google Vision API 的 CameraSource 中实现以构建相机并在捕获图像之前进行面部检测。现在我遇到了一些问题,所以我需要从 CameraSource 访问相机对象。
这是我的 CameraSource Builder
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
Run Code Online (Sandbox Code Playgroud)
在这里,我必须尝试从 mCameraSource 对象访问/获取相机。
Field[] declaredFields = CameraSource.class.getDeclaredFields();
for (Field field : declaredFields) {
if (field.getType() == Camera.class) {
field.setAccessible(true);
try {
Camera camera = (Camera) field.get(mCameraSource);
if (camera != null) {
Camera.Parameters params = camera.getParameters();
params.setExposureCompensation(1500);
camera.setParameters(params);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
但camera
只返回空值,我的第二个问题是如何做亮度选项......
if (camera != null) { …
Run Code Online (Sandbox Code Playgroud) 在开发中我只使用:
@vision = Google::Cloud::Vision.new( project: "instacult",
keyfile: "path/to/keyfile.json" )
Run Code Online (Sandbox Code Playgroud)
其中keyfile是谷歌在创建服务帐户后生成的json(https://cloud.google.com/vision/docs/common/auth).
但显然我不能只将密钥文件上传到github.
我尝试将整个json保存到Heroku的配置变量并运行:
Rails.env.production? ? ENV["GOOGLE_CREDENTIALS"] : path
Run Code Online (Sandbox Code Playgroud)
但是我在heroku的日志中得到"不是一个有效的文件".由于我没有传递文件而是传递对象,因此似乎是合乎逻辑的.但是如何克服它呢?
干杯,凯
我正在尝试按照此示例使用 Barcode API https://github.com/googlesamples/android-vision/tree/master/visionSamples/barcode-reader但无法让 BarcodeDetector 工作。
BarcodeDetector 无法运行。日志中充满了以下两条消息:
11-18 17:01:17.346 6661-6800/me.androidwrapper I/Vision: Loading library libbarhopper.so
11-18 17:01:17.347 6661-6800/me.androidwrapper I/Vision: libbarhopper.so library load status: false
Run Code Online (Sandbox Code Playgroud)
我假设无法下载该库。我有 4 GB 可用内存。
gradle.build
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "me.androidwrapper"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0' …
Run Code Online (Sandbox Code Playgroud)