获取捕捉坐标完成
新bug: 目前画面出现了多余的人体遮罩
This commit is contained in:
parent
08a5f711a9
commit
59387de36f
|
@ -1,17 +1,17 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="deploymentTargetDropDown">
|
<component name="deploymentTargetDropDown">
|
||||||
<targetSelectedWithDropDown>
|
<runningDeviceTargetSelectedWithDropDown>
|
||||||
<Target>
|
<Target>
|
||||||
<type value="QUICK_BOOT_TARGET" />
|
<type value="RUNNING_DEVICE_TARGET" />
|
||||||
<deviceKey>
|
<deviceKey>
|
||||||
<Key>
|
<Key>
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
<type value="SERIAL_NUMBER" />
|
||||||
<value value="$USER_HOME$/.android/avd/Pixel_3a_API_33_x86_64.avd" />
|
<value value="adb-3040223527000PT-yH8BGJ._adb-tls-connect._tcp" />
|
||||||
</Key>
|
</Key>
|
||||||
</deviceKey>
|
</deviceKey>
|
||||||
</Target>
|
</Target>
|
||||||
</targetSelectedWithDropDown>
|
</runningDeviceTargetSelectedWithDropDown>
|
||||||
<timeTargetWasSelectedWithDropDown value="2023-01-10T13:25:57.409214Z" />
|
<timeTargetWasSelectedWithDropDown value="2023-01-17T14:13:43.027203Z" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -15,6 +15,7 @@ import com.google.mediapipe.components.PermissionHelper
|
||||||
import com.google.mediapipe.formats.proto.LandmarkProto.NormalizedLandmarkList
|
import com.google.mediapipe.formats.proto.LandmarkProto.NormalizedLandmarkList
|
||||||
import com.google.mediapipe.framework.AndroidAssetUtil
|
import com.google.mediapipe.framework.AndroidAssetUtil
|
||||||
import com.google.mediapipe.framework.PacketGetter
|
import com.google.mediapipe.framework.PacketGetter
|
||||||
|
import com.google.mediapipe.framework.ProtoUtil
|
||||||
import com.google.mediapipe.glutil.EglManager
|
import com.google.mediapipe.glutil.EglManager
|
||||||
import com.google.protobuf.InvalidProtocolBufferException
|
import com.google.protobuf.InvalidProtocolBufferException
|
||||||
|
|
||||||
|
@ -80,14 +81,18 @@ class MainActivity : AppCompatActivity() {
|
||||||
processor.videoSurfaceOutput.setFlipY(true)
|
processor.videoSurfaceOutput.setFlipY(true)
|
||||||
|
|
||||||
|
|
||||||
// 展示
|
// 捕获获得的坐标数据包
|
||||||
|
// 遇到InvalidProtocolBufferException
|
||||||
|
// 参考 https://github.com/google/mediapipe/issues/1013
|
||||||
|
ProtoUtil.registerTypeName(NormalizedLandmarkList::class.java,
|
||||||
|
"mediapipe.NormalizedLandmarkList")
|
||||||
processor.addPacketCallback(
|
processor.addPacketCallback(
|
||||||
outputLandmarksStreamName
|
outputLandmarksStreamName
|
||||||
) {
|
) {
|
||||||
|
Log.i(tag, "Received Landmark Packets.")
|
||||||
try {
|
try {
|
||||||
val landmarkRaw = PacketGetter.getProtoBytes(it)
|
val landmarkList = PacketGetter.getProto(it, NormalizedLandmarkList::class.java)
|
||||||
val poseLandmarks = NormalizedLandmarkList.parseFrom(landmarkRaw)
|
Log.i(tag, getPoseLandmarksDebugString(landmarkList))
|
||||||
// 从这里可以获得每个特征点的座标
|
|
||||||
} catch (exception: InvalidProtocolBufferException) {
|
} catch (exception: InvalidProtocolBufferException) {
|
||||||
Log.e(tag, "failed to get protocol.", exception)
|
Log.e(tag, "failed to get protocol.", exception)
|
||||||
}
|
}
|
||||||
|
@ -248,4 +253,26 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化输出捕捉的标志位置
|
||||||
|
*/
|
||||||
|
private fun getPoseLandmarksDebugString(poseLandmarks: NormalizedLandmarkList): String {
|
||||||
|
val debugString = StringBuilder("Pose LandMarks: " + poseLandmarks.landmarkCount + "\n")
|
||||||
|
for ((landMarkIndex, landmark) in poseLandmarks.landmarkList.withIndex()) {
|
||||||
|
debugString.append(
|
||||||
|
"\tLandMark ["
|
||||||
|
+ landMarkIndex
|
||||||
|
+ "]: ("
|
||||||
|
+ landmark.x
|
||||||
|
+ ","
|
||||||
|
+ landmark.y
|
||||||
|
+ ","
|
||||||
|
+ landmark.z
|
||||||
|
+ ")\n"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return debugString.toString()
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user