trettenbrein/OpenPoseR

Using file_clean() fails for "hands" model

Closed this issue · 1 comments

When using file_clean()for the data for the "hands" model I get the following error:

Error in if (data[row, paste("c", point, sep = "")] <= cutoff) { : argument is of length zero
2. clean_data(data, model, cutoff) at file_clean.R#38
1. file_clean(paste(outputdir, filename, "_hand_left.csv", sep = ""), cutoff = 0.4, overwrite = FALSE)

It seems that clean_data() contains a hardcoded number of columns (0:24, i.e. 25) which is the default of the BODY25 model, but will fail for other models:

# Check probability for every tracked point in data frame; remove if necessary
  for(row in 1:nrow(data)) {
    for(point in 0:24) {
      # Confidence in tracking smaller than or equal to cutoff?
      if(data[row,paste("c", point, sep = "")]<=cutoff) {
        # Set data points (x, y) and c to 0
        data[row,paste("x", point, sep = "")] <- 0
        data[row,paste("y", point, sep = "")] <- 0
        data[row,paste("c", point, sep = "")] <- 0
      }
    }
  }